How to Deploy Bandwidthd Open-Source Traffic Monitor on CentOS 6.3

       With bandwidthd, you can view the traffic of each IP passing through the gateway via a web interface from any computer using a browser. It is displayed by protocol, color-coded, and includes intuitive graph curves.
In daily maintenance, the biggest headache for network administrators is internal users frequently transferring large files, which slows down the already limited bandwidth. If you install bandwidthd on the gateway, you can track the traffic of each IP and display it using graph curves for different protocols, and you can also view it by time periods.
For example: it shows the individual traffic of FTP, HTTP, P2P, TCP, UDP, and ICMP protocols, using IP as the statistical object.

 
1. Install Basic Build Components
[root@localhost ~]# yum install gcc cpp glibc glibc-devel gcc-c++
 
2. PCAP/PNG/GD Library (Image Processing Library)
[root@localhost ~]# yum install libpcap libpcap-devel libpng libpng-devel gd gd-devel
 
3. Install httpd
[root@localhost ~]# yum install httpd mod_ssl
[root@localhost ~]# service httpd start
[root@localhost ~]# chkconfig httpd on
 
4. Download bandwidthd
[root@localhost ~]#
wget http://jaist.dl.sourceforge.net/project/bandwidthd/bandwidthd/bandwidthd%202.0.1/bandwidthd-2.0.1.tgz
 
5. Install bandwidthd
Extract bandwidthd
[root@localhost ~]# tar -zxvf bandwidthd-2.0.1.tgz
Compile
[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
total 64
-rwxr-xr-x 1 root root 53320 Mar 19 15:15 bandwidthd   //bandwidthd startup file
drwxr-xr-x 2 root root  4096 Mar 19 15:51 etc          //configuration file
drwxr-xr-x 2 root root  4096 Mar 19 15:25 htdocs       //web access directory, you can point a virtual host here
 
6. Modify the bandwidthd Configuration File
[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       #Set the monitored network segment
#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"  #(This is the network card ethx or any you want to monitor, can be adjusted to the corresponding network connection device)
 
###################################################
# 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  #Default refresh every 2.5 minutes
 
# Graph cutoff is how many k must be transfered by an
# ip before we bother to graph it
graph_cutoff 1024   #Default graph only for traffic above 1M
 
#Put interface in promiscuous mode to score to traffic
#that may not be routing through the host machine.
#promiscuous true   #Set the network card to promiscuous mode for recording
 
#Log data to cdf file htdocs/log.cdf
output_cdf true   #Generate log2.cdf in the bandwidthd directory; record data in log.cdf format
 
#Read back the cdf file on startup
recover_cdf true   #Re-read the cdf data when starting bandwidthd
 
#Libpcap format filter string used to control what bandwidthd see's
#Please always include "ip" in the string to avoid strange problems
filter "ip"   #Use ip as the filter object
 
#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    #Graph generation
 
#Set META REFRESH seconds (default 150, use 0 to disable).
meta_refresh 150   #Web page refresh time

:wq               #Save
 
7. Create a Symlink to bandwidthd in the Web Root Directory, Execute
[root@localhost ~]# cd /var/www/html/
[root@localhost html]# ln -s /usr/local/bandwidthd/htdocs bandwidthd
 
8. Start bandwidthd and httpd
[root@localhost ~]#cd /usr/local/bandwidthd
[root@localname bandwidthd]#./bandwidthd
[root@localhost bandwidthd]# service httpd restart
 
9. Set bandwidthd to Start Automatically on Boot
[root@localhost ~]# vim /etc/rc.local
Add the following content at the end:
#bandwidthd traffic monitor
/usr/local/bandwidthd/bandwidthd
 
11. After a few minutes, you can browse the graphical reports generated by bandwidthd
http://IP/bandwidthd

 
This article is from “运维IT” blog, please be sure to keep this source http://yanghuawu.blog.51cto.com/2638960/1160334

Leave a Comment

Your email address will not be published.