Beyond the Sky

The place where surface stop and share the experience of life

Subscribe to RSS feed

Setup MRTG

,

The Multi Router Traffic Grapher (MRTG) is a tool to monitor the traffic load on network links. NTOP doesn't shows the in and out traffic separately, I would like to see my in and out traffic clearly so I setup MRTG. Setup MRTG is not a "simple" task. My defination of simple is yum install or apt-get install it and ready for use.

For setting up MRTG, you need some steps. First talks about dependency, install all the packages listed as bellow:

net-snmp                       
net-snmp-libs
net-snmp-utils
mrtg


Yum or apt-get it all. Verify what you have, you must have mrtg folder at /var/www. For my case my working html folder is at /var/www/html. so first thing I do is:
mv /var/www/mrtg /var/www/html


Configure /etc/snmp/snmpd.conf, add in the community key you enter, you gonna use it later.
rocommunity public

For this case, "public" is your community key.

chkconfig snmpd on

Keep in mind if you use ubuntu or debian based distro, change the entry of K50snmpd to K50snmpd at /etc/rc2. ( rc? depend on you startup id you used, check first few line of /etc/initab

Start snmp service
service snmpd start
or
sudo /etc/init.d/snmpd start 


Check whether snmp is is working, try few times.
snmpwalk -v 1 -c public localhost interface

Replace with your community key if you have specified other name.

Configure MRTG, if have existing mrtg.cfg backup it
cd /etc/mrtg
cfgmaker public@192.168.1.1 > mrtg.cfg

Assume public is community key and 192.168.1.1 is your IP address. This command with create a simple mrtg configuration file, change the working directory.
vi mrtg.cfg

Check this line
WorkDir: /var/www/html/mrtg


Create a nice index.html for mrtg.
indexmaker -title 'My MRTG' -output /var/www/html/mrtg/index.html /etc/mrtg/mrtg.cfg

Almost done, set crontab now.
[CODE]vi /etc/crontab

Addin this line:
*/5 * * * * root /usr/bin/mrtg /etc/mrtg/mrtg.cfg 


This makes crontab service run this line every 5 minutes and update the graph. Restart crontab and you are done.
 service crond restart
or
 sudo /etc/init.d/crond restart 


Now go http://localhost/mrtg and check out.


Special thanks to Simon Teh from NRG USM guiding me on setup MRTG on my home machine.