MRTG (The Multi Router Traffic Grapher) is a very cool application. It runs on Linux, OS X and also under Windows (with Perl support) and it can draw graphs about everything (everything that support SNMP). I use this piece of software to monitor network interfaces and of course routers.
With Cisco routers you need to enable the SNMP support under the CLI. So, after the telnet connection, become “superuser” (the enable command) and create the SNMP community:

router# enable
router# configure terminal
router(config)# snmp-server community CommunityName RO
router(config)# exit
router#

PS: if you get MRTG working, you can run also the command wr memory to save the router config so you can reboot the device without loosing settings:

router# wr memory

Now, under your Linux system (on the others systems these steps may be similar…) you need only to install with your favorite package manager the MRTG package. After becoming root as usual (with su or sudo -s) run this command (create before the dir /var/www/html/mrtg and /etc/mrtg):

linux@host# cfgmaker –global ‘WorkDir: /var/www/html/mrtg’
–output /etc/mrtg/mrtg.cfg CommunityName@192.168.0.254

You can now run the mrtg program with the config file as option:

linux@host# mrtg /etc/mrtg/mrtg.cfg

Now your router traffic will be graphed! (check http://your_linux_server/mrtg/)
Is a good idea to create a cron job to update the graph every five minutes. Create a file into /etc/cron.d named mrtg.cron with this content:

0-59/5 * * * * root /usr/bin/mrtg /etc/mrtg/mrtg.cfg

PS: Into this little tutorial I suppose the presence of a running Linux server with apache installed and a Cisco router with the private address 192.168.0.254. Also all programs path may change due to your system/distro…
I don’t cover all possible security improvements (like protect your router from Internet, setting htaccess password to your web server, etc…). But remember always to check twice all your potential security issues.

14 Comments

Dex · October 20, 2006 at 03:42

I followed your tutorial and get this :

# /usr/bin/cfgmaker –global ‘WorkDir:/srv/www/htdocs/mrtg’ –output /etc/mrtg/mrtg.cfg ro@222.224.28.8

–base: Get Device Info on ro@222.224.28.8:
SNMP Error:
no response received
SNMPv1_Session (remote host: “222.224.28.8” [222.224.28.8].161)
community: “ro”
request ID: -221942610
PDU bufsize: 8000 bytes
timeout: 2s
retries: 5
backoff: 1)
at /usr/bin/../lib/mrtg2/SNMP_util.pm line 627
SNMPWALK Problem for 1.3.6.1.2.1.1 on ro@222.224.28.8::::::v4only
at /usr/bin/cfgmaker line 796
WARNING: Skipping ro@222.224.28.8: as no info could be retrieved

–base: Writing /etc/mrtg/mrtg.cfg

What is the problem here, help please.
Thanks.

Paolo · October 30, 2006 at 21:03

Hi Dex,
your IP 222.224.28.8 seems to be a public address. Usually SNMP on router CISCO can be easily reached from the INSIDE interface and not from outside. To allow the SNMP query from Internet, you need to setup some ACL on your router console on trusted IP.

GR Seshagiri · April 30, 2007 at 07:57

Hi Paolo,

Your site was of immense help to me to get the MRTG working. Thank you so much for your detailed instructions.

–seshagiri

George Mason · July 17, 2007 at 16:34

Great tutorial, helped me out no end – why couldn’t everyone else put it so simply! Thanks very much.

George

Rauf · April 9, 2008 at 09:23

I must appreciate your compact and concise tutorial which helped me out. If u could plz mention some thing about ‘how to view the graphs in windows environment. Thanx

Bassam · June 25, 2008 at 23:27

i need to know how to monitor cisco routers memory and cpu by MRTG

Rich · June 26, 2008 at 22:45

Ok that was far too simple. I’ve spent an hour reading over Cisco SNMP specifications and trying to work out how I can graph our WAN link, and which of the million or so (or so it seems) MIB values will output what I need.

After reading your very brief howto, and running cfgmaker it’s all working perfectly within a couple of minutes!

Brilliant! Thank you so much!

Arsenic · July 30, 2008 at 11:49

Thank’s for your howto, it helped me to monitor my wan link, and i am very happy because before that i have spent lot of time to search what was the source of the errors in my config command line !

Talile · October 25, 2008 at 13:05

Your site is of great help but when I enter:
cfgmaker –global “workDir: /home/tmiresa/public_html/mrtg” –output /home/tmiresa/mrtg/mrtg.cfg ro@10.140.67.3

This error:

Error:
can’t resolve ” ro@10.140.67.3″to IP address
at /usr/share/perl5/SNMP_util.pm line 426
SNMPWALK Problem for publicro@10.140.67.3::::::v4only
at /usr/bin/cfgmaker line 921
WARNING: Skipping publicro@10.140.67.3: as no info could be retrieved

What is the problem here, help please.
Thanks in advance!

Paolo · October 30, 2008 at 00:52

Hi Talile,
have you tried to install SNMP/SNMPWALK in your server (the machine with cfgmaker)?

Evelyne Schweigart · April 16, 2010 at 13:56

Good site i love it

Nick Potts · July 13, 2010 at 15:13

Paolo thanks so much for this keep them coming, Nick

Jenn · October 15, 2010 at 09:23

Hi Paolo,

I have the same problem with Talile. SNMPWALK problem. SNMP daemon is running on the linux server where the MRTG is running on.

Any advice for this?

Thanks so much.

bubby · June 1, 2011 at 10:18

Wonderful link 🙂

Leave a Reply

Avatar placeholder

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