Chinaunix首页 | 论坛 | 博客
  • 博客访问: 1654754
  • 博文数量: 135
  • 博客积分: 2820
  • 博客等级: 少校
  • 技术积分: 2544
  • 用 户 组: 普通用户
  • 注册时间: 2010-09-16 13:33
文章分类

全部博文(135)

文章存档

2015年(1)

2014年(8)

2013年(16)

2012年(43)

2011年(56)

2010年(11)

分类:

2011-04-06 10:18:47

下载bandwidthd

1安装bandwidthd
tar zxf bandwidthd-2.0.1.gz
cd bandwidthd
more INSTALL.Unix  看安装说明,有三个相关软件需要提前安装。
libpcap from

libpng from
libgd from
1.1 安装libpcap
tar zxf libpcap-0.9.7.tar.gz
./configure
make && make install
1.2安装libpng-1.2.18.tar.gz
tar zxf libpng-1.2.18.tar.gz
./configure
make && make install
1.3安装gd-2.0.35.tar.gz
tar zxf gd-2.0.35.tar.gz
./configure
make 
make install
上面这三个安装完毕之后,就可执行./configure && make install 进行bandwidthd安装。

执行:./configure 会报错
提示:error: Bandwidthd requires but cannot libpng
解决:export CFLAGS="-I/usr/include/libpng12"
         export LIBS="-lpng12 -lz -lm"  

执行:./configure 会报错
提示:error: Bandwidthd requires but cannot libgd
解决:我解决这个问题是重新安装gd库,卸载自带的包,安装源码包。

执行:make insall
提示:make: *** [bandwidthd] Error 1
解决:ln -s /usr/local/lib/libgd.so.2 /usr/lib64/libgd.so.2
执行:/usr/local/bandwidthd/bandwidthd
提示:error while loading shared libraries: libpng12.so.0
解决:export LD_LIBRARY_PATH=/usr/local/lib

2配置bandwidthd.conf
vi /usr/local/bandwidthd/etc/bandwidthd.conf
subnet 192.168.0.0/16
graph_cutoff 30  流量达到30k的才进行绘图
graph true
3启动、关闭bandwidthd
/usr/local/bandwidthd/bandwidthd
 
启动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
 关闭bandwidthd
killall bandwidthd
4、web访问方式建立
ln -s /usr/local/bandwidthd/htdocs /var/www/html/band
就可以看bandwidthd页面,几分钟后就可以看流量显示。
 
另外,更多配置方法:
1. 把设定档中的 dev 增加更多的dev,或设成 any 可以监控更多设备
2. 如果认为TOP20太少了,
就在还没MAKE时候先改graph.c
graph.c中查找
for (Counter=0; Counter < 21 && Counter < NumIps; Counter++)
把21改成101
就变成TOP100
然后查找TOP20改为字符串TOP100
然后存盘,再make install 即可.
 
配置文件详解:
 
1 vi /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.0.0.0 255.0.0.0
#subnet 192.168.0.0/16
#subnet 172.16.0.0/12
subnet 184.82.43.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"  #(这是你要检测的网卡,可以调整为对应的网络连接设备) 
 
###################################################
# 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   #网页刷新时间
 
存盘之后,便可生效。 


 
阅读(2745) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~