CentOS開源流量監視軟體Bandwidthd
用bandwidthd在任何一台電腦可以通過web介面用瀏覽器查看經過網關的各個ip流量,而且是分協議,分顏色顯示,已經有直觀的圖象曲線.
在日常維護中, 網管人員最頭痛的是內部網經常有人在大量傳送檔案而導致本來可憐的頻寬變得更加緩慢.如果在網關上裝上bandwidthd ,就可以追蹤的是各個的 IP 的流量,而且可以用圖象曲線顯示各個ip的相應不同協議顯示,還能分時段查看,
例如:包含FTP、HTTP、P2P、TCP、UDP、ICMP協議的各自流量,以IP為統計對象.
1、基本編譯組件安裝
[root@localhost ~]#yum-y install gcc cpp glibc glibc-devel gcc-c++
2.、PCAP/PNG/GD Library(影像處理庫)
[root@localhost ~]#yum-y install libpcap libpcap-devel libpng libpng-devel gd gd-devel
3、安裝httpd
[root@localhost ~]#yum-y install httpd mod_ssl
[root@localhost ~]# service httpd start
[root@localhost ~]# chkconfig httpd on
4、下載bandwidthd
[root@localhost ~]#
wgethttp://jaist.dl.sourceforge.net/project/bandwidthd/bandwidthd/bandwidthd%202.0.1/bandwidthd-2.0.1.tgz
5、安裝bandwidthd
解壓bandwidthd
[root@localhost ~]#tarzxvf 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;makeinstall
[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
#Bandwidthdlistens on the first device it detects
# by default. Run “bandwidthd -l” for a list of
# devices.
dev “any” #(這是你要檢測的網卡ethx或any(所有),可以調整為對應的網路連接裝置)
###################################################
# Options that don’t usually get changed
# An interval is 2.5 minutes, this is how many
# intervalsto skip before doing a graphing run
skip_intervals1 #預設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 cdffile htdocs/log.cdf
output_cdftrue #在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.Bandwidthdwill 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、啟動bandwidthd、httpd
[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