Thursday, 10 March 2016

Using MRTG to monitor bandwidth on your network (SNMP)

MRTG is a tool that logs bandwdith information via SNMP from a network device such as a switch and archives it providing an historic overview of bandwidth utilization. 

We should firstly install the necessary packages:

yum install mrtg net-snmp net-snmp-utils

and create a configuration for your SNMP enabled device with:

cfgmaker --global 'WorkDir: /var/www/mrtg' --output /etc/mrtg/mrtg.cfg public@router

(where 'public' is your community string.)

We can manually invoke MRTG with:

/usr/bin/indexmaker --output=/var/www/mrtg/index.html /etc/mrtg/mrtg.cfg

But we will probably want to setup a cron job to run periodically for us!

So we create the following:

/etc/cron.d/mrtg

and add something like:

0,5,10,15,20,25,30,35,40,45,50,55 * * * * /usr/bin/indexmaker --output=/var/www/mrtg/index.html /etc/mrtg/mrtg.cfg

Also ensure the cron daemon is running / will start on boot:

sudo chkconfig crond on
sudo service crond start

0 comments:

Post a Comment