Sunday, August 7, 2011

Lazy mrtg graphs with Debian + Cisco

1 - SSH / telnet / whatever to your router and enable snmp :

  • Cisco#Config t
  • Cisco(config)#snmp-server community public RO
  • Cisco(config)#end
  • (you may need to modify ACL to allow traffic to the snmp port)

2 - Install snmp, mrtg and your favorite web server packages on your debian - lighthttpd in this case:

  • Nova# sudo apt-get update
  • Nova# sudo apt-get install mrtg lighttpd snmp 
  • (Satisfy all the depencies shown)

3 - Check snmp is working properly:

  • Nova# snmpwalk -v 2c -C public <router IP>
  • (You should be seeing lots of strings, then it works!)

4 - Create the templates for mrtg:

  • Nova# sudo cfgmaker -global WorkDir:/var/www/mrtg --output=/etc/mrtg/myrouter.cfg public@<router IP>
  • (You might want to edit the cfg file to customize the options, interfaces, etc. I always add Options[_]:growright)

5 - Create the file /etc/cron.d/mrtg with this content and make cron check your device:

       */5 * * * * root env LANG=C /usr/bin/mrtg /etc/mrtg/myrouter.cfg 2>&1

6 - Create the index file for viewing the graphs executing this command:

  • Nova# sudo indexmaker --sort=title --output=/var/www/mrtg/index.html /etc/mrtg/myrouter.cfg


8 - Configure your browser to be able to show the index.html created before.

9 - Open the html file with your browser (http://localhost/mrtg ?)

10 - Wait some minutes to check all the graphs are showing properly :)

No comments:

Post a Comment