CentOS6.3环境下实战Linux开源流量监控软件Bandwidthd

简介:

bandwidthd在任何一台电脑可以通过web界面用浏览器查看经过网关的各个ip流量,而且是分协议,分颜色显示,已经有直观的图象曲线.

在日常维护中网管人员最头痛的是内部网经常有人在大量传送文件而导致本来可怜的带宽变得更加缓慢.如果在网关上装上bandwidthd ,就可以追踪的是各个的 IP 的流量,而且可以用图象曲线显示各个ip的相应不同协议显示,还能分时段查看
例如:包含FTPHTTPP2PTCPUDPICMP协议的各自流量,IP为统计对象.

 

1、基本编译组件安装

[root@localhost ~]# yum install gcc cpp glibc glibc-devel gcc-c++

 

2.PCAP/PNG/GD Library(图像处理库)

[root@localhost ~]# yum install libpcap libpcap-devel libpng libpng-devel gd gd-devel

 

3、安装httpd

[root@localhost ~]# yum install httpd mod_ssl

[root@localhost ~]# service httpd start

[root@localhost ~]# chkconfig httpd on

 

4、下载bandwidthd

[root@localhost ~]#

wget http://jaist.dl.sourceforge.net/project/bandwidthd/bandwidthd/bandwidthd%202.0.1/bandwidthd-2.0.1.tgz

 

5、安裝bandwidthd

解压bandwidthd

[root@localhost ~]# tar -zxvf bandwidthd-2.0.1.tgz

编译

[root@localhost ~]#cd bandwidthd-2.0.1

[root@localhost bandwidthd-2.0.1]# ./configure

[root@localhost bandwidthd-2.0.1]# make;make install

 

[root@localhost ~]# ll /usr/local/bandwidthd

总用量 64

-rwxr-xr-x 1 root root 53320 3  19 15:15 bandwidthd   //启动bandwidthd文件

drwxr-xr-x 2 root root  4096 3  19 15:51 etc          //配置文件

drwxr-xr-x 2 root root  4096 3  19 15:25 htdocs       //web访问目录,可以作一个虚拟主机指过来

 

6、修改bandwidthd配置文件

[root@localhost ~]# vim /usr/local/bandwidthd/etc/bandwidthd.conf

####################################################

# Bandwidthd.conf

#

# Commented out options are here to provide

# documentation and represent defaults

 

# Subnets to collect statistics on.  Traffic that

# matches none of these subnets will be ignored.

# Syntax is either IP Subnet Mask or CIDR

subnet 10.1.3.0 255.255.255.0       #设置监控的网段

#subnet 192.168.0.0/24

subnet 172.16.1.0/24

 

# Device to listen on

# Bandwidthd listens on the first device it detects

# by default.  Run "bandwidthd -l" for a list of

# devices.

dev "any"  #(这是你要检测的网卡ethxany(所有),可以调整为对应的网络连接设备)

 

###################################################

# Options that don't usually get changed

 

# An interval is 2.5 minutes, this is how many

# intervals to skip before doing a graphing run

skip_intervals 1  #默认2.5 minutes 刷新

 

# Graph cutoff is how many k must be transfered by an

# ip before we bother to graph it

graph_cutoff 1024   #默认1M 以上的流量才有图形

 

#Put interface in promiscuous mode to score to traffic

#that may not be routing through the host machine.

#promiscuous true   #设置网卡在混杂模式中记录

 

#Log data to cdf file htdocs/log.cdf

output_cdf true   #bandwidthd目录中生成log2.cdf  log.cdf格式数据记录

 

#Read back the cdf file on startup

recover_cdf true   #在启动bandwidth时重新读取cdf的数据

 

#Libpcap format filter string used to control what bandwidthd see's

#Please always include "ip" in the string to avoid strange problems

filter "ip"   #ip为过滤对象

 

#Draw Graphs – This default to true to graph the traffic bandwidthd is recording

#Usually set this to false if you only want cdf output or

#you are using the database output option.  Bandwidthd will use very little

#ram and cpu if this is set to false.

graph true    #图形生成

 

#Set META REFRESH seconds (default 150, use 0 to disable).

meta_refresh 150   #网页刷新时间

:wq               #保存

 

7、在web 主目录下做bandwidthd软连接,执行

[root@localhost ~]# cd /var/www/html/

[root@localhost html]# ln -s /usr/local/bandwidthd/htdocs bandwidthd

 

8、启动bandwidthdhttpd

[root@localhost ~]#cd /usr/local/bandwidthd

[root@localname bandwidthd]#./bandwidthd

[root@localhost bandwidthd]# service httpd restart

 

9、设定开机自动启动 bandwidthd

[root@localhost ~]# vim /etc/rc.local

在最后添加内容:

#bandwidthd流量监控

/usr/local/bandwidthd/bandwidthd

 

11、过几分钟,就可以浏览bandwidthd 生成的图形报表

http://IP/bandwidthd

 




本文转自 yhw85 51CTO博客,原文链接:http://blog.51cto.com/yanghuawu/1160334,如需转载请自行联系原作者

相关文章
|
18天前
|
Linux
Linux中centos桌面消失网络图标
Linux中centos桌面消失网络图标
13 0
|
21天前
|
JSON Kubernetes Linux
Linux环境签发CA证书和K8s需要的证书
Linux环境签发CA证书和K8s需要的证书
23 0
|
1月前
|
存储 缓存 Linux
如何在Linux环境下对pip的缓存地址进行修改
如何在Linux环境下对pip的缓存地址进行修改
|
1月前
|
运维 Linux Apache
Linux Apache服务详解——Apache虚拟目录与禁止显示目录列表实战
Linux Apache服务详解——Apache虚拟目录与禁止显示目录列表实战
22 2
|
8天前
|
存储 算法 Linux
【实战项目】网络编程:在Linux环境下基于opencv和socket的人脸识别系统--C++实现
【实战项目】网络编程:在Linux环境下基于opencv和socket的人脸识别系统--C++实现
24 6
|
10天前
|
关系型数据库 MySQL Linux
linux CentOS 7.4下 mysql5.7.20 密码改简单的方法
linux CentOS 7.4下 mysql5.7.20 密码改简单的方法
17 0
|
21天前
|
应用服务中间件 Linux PHP
Linux下安装php环境并且配置Nginx支持php-fpm模块
Linux下安装php环境并且配置Nginx支持php-fpm模块
18 0
|
23天前
|
Java Linux
linux安装jdk环境
linux安装jdk环境
28 0
|
30天前
|
存储 缓存 Linux
Linux 系统调用深思:从原理到实战
Linux 系统调用深思:从原理到实战
39 1
|
30天前
|
监控 网络协议 Linux
Linux 命令大全 & CentOS常用运维命令
Linux 命令大全 & CentOS常用运维命令
139 0