Sunday, July 22, 2007

Traffic Monitoring with MRTG

To monitor your network performance and traffic folw, you need to setup 1 NMS box in your network.MRTG can monitor SNMP network devices and show how much traffic has passed through the interfaces.

MRTG can run on both Unix/linux and Windows.For installion, can download from http://oss.oetiker.ch/mrtg/


Here's simple and quick configuration guide to add your devices into MRTG.
Once you installed MRTG and Apache is running, add your devices with these following steps
- Enable SNMP on device

- Get the SNMP community String

- Allow SNMP connection from MRTG box to poll data

- If the device is under firewall, open the rule for it


If you have all of these, you are ready to add your devices.
- Go to your MRTG installed path..#cd /usr/local/mrtg
- Create cfg file for device.

#./cfgmaker SNMP-community-srting@IP-address-of-device > device.cfg

for example; #./cfgmaker readonly@192.168.1.1 >192.168.1.1.cfg

MRTG will collect the SNMP info and create the cfg file 192.168.1.1.cfg
- Verify your file.#ls -al your config file is 192.168.1.1.cfg
- Modify cfg file using vi Editor

(vi ref gide - http://www.unix-manuals.com/refs/vi-ref/vi-ref.htm)

#vi 192.168.1.1.cfg

Add following lines to Specify the path for your running directory.

htmldir: /usr/local/mrtg/www

Imagedir:/usr/local/mrtg/www

Logdir: /usr/local/mrtg/log
save and quit the file with :wq
- Start MRTG with this command

#/usr/local/mrtg/mrtg /usr/local/mrtg/192.168.1.1.cfg

run this command 3 or 4 times.
- Create index file to view with Apache.

#./indexmaker 192.168.1.1.cfg

Verify under your html path /usr/local/mrtg/www

You should see index.html file and your graphs.
- View your graphs via browserhttp://your-mrtg-IP/www/ (depends on your Apache config)
You will see your MRTG graphs. Like this..http://www.stat.ee.ethz.ch/mrtg/

But your graphs will not move. You need to add cron jobs to poll by MRTG every 5 min.
- Add cron jobs.

#crontab -l (view your currnet crons)#crontab -e (add your cron)5,10,15,20,25,30,35,40,45,50,55,00 * * * * usr/local/mrtg/mrtg /usr/local/mrtg/192.168.1.1.cfg
After 5 or 10 mins, you will see your graphs.
Done!!!!
This is only for quick ref. For more details info and ref, goto: http://oss.oetiker.ch/mrtg/

No comments: