bandwidthd的安装配置

在流量统计常用免费软件中有mrtg,ntop,bandwidthd等多种, 
mrtg 只是显示某一网络接口的总量, ntop详细但也较占系统资源。 

现在试试bandwidthd,它可在各种unix下运行。 

网关上装上'bandwidthd' ,就可以追踪的是各个的 IP 的流量,而且可以用图象曲线显示各个ip的相应不同协议显示,还能分时段查看 
例如包含HTTP, TCP, UDP, ICMP, VPN 以及 P2P 协议的各自流量,以ip为统计对象。 

默认的颜色,TCP为绿色;HTTP为蓝色;FTP为浅蓝;P2P为粉红;UDP为棕褐色; ICMP为红色。 

安装: 
更新ports后, 
cd /usr/ports/net-mgmt/bandwidthd/ 
make -s install distclean 
就装好了。 

在你的web的根目录建立一个叫bandwidth的目录, 
ln -s /web的根目录/bandwidth/ /usr/local/bandwidthd/htdocs 

cp /usr/local/bandwidthd/etc/bandwidthd.conf-dist /usr/local/bandwidthd/etc/bandwidthd.conf

修改配置: 
vi /usr/local/bandwidthd/etc/bandwidthd.conf 

一般修改一下网段和掩码,其他的用默认值即可,如果你熟悉英文,就看看其他选项.大概如下 
编辑: 
/usr/local/bandwidthd/etc/bandwidthd.conf 
#################################################### 
# Bandwidthd.conf 

# Commented out options are here to provide 
# documentation and represent defaults 

# Subnets to collect statistics on 
#subnet 10.0.0.0 255.0.0.0 
#subnet 208.16.191.0 255.255.255.0 
subnet 192.168.1.250 255.255.255.0 #以一网段为例 
# Device to listen on 
dev "eth0" #(这是你要检测的网卡,可以调整为对应的网络连接设备) 
把其中 subnet 的设定,以一网段为例: 
subnet 192.168.1.0 255.255.255.0 
################################################### 
# 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 0 #默间隔认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 在bandwidthd中生成log2.cdf log.cdf格式数据记录 
output_cdf true 

#Read back the cdf file on startup 在启动bandwidth时重新读取cdf的数据 
recover_cdf true 

#Libpcap format filter string used to control what bandwidthd see's 
#Please always include "ip" in the string to avoid strange problems 
#以ip为过滤对象 
filter "ip" 

#Draw Graphs 
graph true 

# List of controled protocols 
# format: item "item_name" rgb_color protocol ports 这是记录的格式:端口名字,RGB颜色,端口号 
# obs.: The yellow (0xffff00) color is predefined to the "TOTAL" item 黄色预设为TOTAL的颜色
item "TCP" 0x00ff00 tcp all 
item "HTTP" 0x0000ff tcp 80 443 
item "FTP" 0xc0c0ff tcp 20 21 
item "P2P" 0xff00ff tcp 1044 1045 1214 4661 4661 4665 5190 5500 5501 5502 5503 6346 6347 6666 6667 7788 8888 8889 28864 288 
65 
item "UDP" 0x800000 udp all 
item "ICMP" 0xff0000 icmp all 

运行: 
cp /usr/local/etc/rc.d/bandwidthd.sh.sample /usr/local/etc/rc.d/bandwidthd.sh 
/usr/local/etc/rc.d/bandwidthd.sh start 
以后server启动后,会自动启动 bandwidthd进程。 

过几分钟后,打开 
http://服务器ip/bandwidth/ 
就可以看到统计结果了。
  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值