I often need to know how much bandwidth is my linux gateway/router box using, specially if there’s any P2P traffic (torrents) and from which IP address on the LAN is it coming. I was searching a lot for a suitable and preferably web based bandwidth monitoring tool, at the end I came up with a program called¬†Bandwidthd that does data collection on it’s own (not SNMP) on the specified interfaces and subnets, and push them in dynamic html pages, with a top list of bandwidth users on your LAN network, what type of traffic are they using (http, p2p, ftp, etc) and apropriate graphs for all of the mentioned.

Initially, it’s not suited for a Centos box, but it’s installable. First, we need the development tools installed:

yum groupinstall ‘Development Tools’

Then a few more packages: libpcap – you can download it from here, then unpack, enter it’s folder, compile and install:

./configure
make
make install

Another package you need is GD, it should be available from the standard repo:

yum install gd gd-devel php-gd

The third package is libpng, also should be available from the repo:

yum install libpng-devel After all the packages are installed, we can try to download the Bandwidthd code and try to compile it. Find the latest release from here, wget and uncompress it, enter it’s folder, and standardly compile it:

./configure
make
make install

All should go smooth, without errors.

Configuring Bandwidthd

We have a few more steps to deploy. First we need to configure Bandwidthd:

vi /usr/local/bandwidthd/etc/bandwidthd.conf

make the options look something like this (there is an extensive explanation in the config file itself about the meaning of each):

subnet <the subnet you wish track>
subnet <if you have another subnet….>
dev “eth0”
skip intervals 0
graph_cutoff 1024
filter “ip”
graph true
meta_refresh 150

Save and exit. BTW, you can add more subnets, as many as you like.  And, under dev, you must enter the proper eth port that you want to use for traffic capture (usually the on on the LAN side) The only thing left is to add an alias for confortable use:

vi /etc/httpd/conf.d/bw.conf

and add at least the line:

alias /bw /user/local/bandwidthd/httpdocs

Save, and exit. Now, start bandwidthd

./usr/local/bandwidthd/bandwidthd

You can add this line to rc.local to make it start on boot. At end, point your web browser to http://<server_ip_address or url>/bw Data should start comming in a few minutes.

Leave a Reply

Your email address will not be published. Required fields are marked *