1.基本编译组件安装
yum install gcc cpp glibc glibc-devel gcc-c++
2. PCAP/PNG/GD Library(图像处理库)
yum install libpcap libpng libpng-devel gd gd-devel
3.安装apache2
yum install httpd mod_ssl
chkconfig httpd on
service httpd start
4.下载bandwidthd
wget http://voxel.dl.sourceforge.net/project/bandwidthd/bandwidthd/bandwidthd%202.0.1/bandwidthd-2.0.1.tgz
5.解压缩bandwidthd
tar -xzvf bandwidthd-2.0.1.tgz
6.修改bandwidthd统计上限(预设为20,修改为100)
cd /usr/local/src/bandwidthd-2.0.1
vi graph.c
Top20修改为Top100 (有4个)#100表示检测的ip数量#
Counter < 21修改为Counter < 101 (有两个)
7.安�bbandwidthd
cd /usr/local/src/bandwidthd-2.0.1
./configure
make install
8.修改bandwidthd配置文件
vi /usr/local/bandwidthd/etc/bandwidthd.conf
引用
####################################################
###################################################
#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 #网页刷新时间
9.建立 Apache 到 bandwidthd 软连接
cd /var/www/html
ln -s /usr/local/bandwidthd/htdocs bandwidthd
启动bandwidthd
cd /usr/local/bandwidthd
./bandwidthd
10.设定开机自动启动 bandwidthd
vi /etc/rc.local
加入/usr/local/bandwidthd/bandwidthd
11.过几分钟,就可以浏览bandwidthd 生成的图形报表了
http://IP/bandwidthd
安装碰到的问题1、bandwidthd编译出会出现:configure: error: Bandwidthd requires but cannot find libpcap
解决办法:http://www.tcpdump.org/release/下载http://www.tcpdump.org/release/libpcap-1.1.1.tar.gz
tar zxvf libpcap-1.1.1.tar.gz
cd libpcap-1.1.1
./configure --prefix=/usr/
make && make install
更新libpcap-devel
yum install libpcap-devel
启动bandwidthd出错
[root@localhost bandwidthd]# ./bandwidthd
./bandwidthd: error while loading shared libraries: libpcap.so.1: cannot open shared object file: No such file or directory
解决办法
[root@localhost bandwidthd]# cd /usr/local/lib/
[root@localhost lib]# cp libpcap.so.1 /usr/lib
[root@localhost lib]#ldconfig
大家可以试下。
http://blog.51wangwei.com/bandwidthd/---转载出处
提示:如果如上Top100 只表示检测这个网段中的ip个IP,但是在页面却不会现实100个IP的状况,默认在图形节目显示20个IP
那么如果想显示更多的IP的状态,只要在刚刚的配置文件中搜索top20 修改为n(n,表示你需要显示的IP数量),修改好后,需要重新编译安装这个软件Bandwidthd