How to use MRTG to generate web traffic for a router

Objective: use MRTG to generate web traffic for a router
Environment:  CentOS 4 and cisco 2501 router


1. Enable SNMP server for cisco router and set the bandwidth for the serial interface
ssh/telnlet into the router with pasword
conf t
snmp-server community public ro

interface serial 0/0
#bandwidth 2048

2. Make sure the udp 161 port is not blocked on cisco router

3. Install MRTG (either through rpm or manual install)

# yum install mrtg

4. Go to MRTG website documention - unix guide at

use the first example command to generate mrtg.cfg

 cfgmaker --global "WorkDir: /home/tobi"           \
          --global "Options[_]: growright,bits"    \
          --ifref=ip                               \
 > mrtg.cfg

note: replace workdir, remove --ifref=ip line.
You might use this command:
/usr/bin/cfgmaker --global 'WorkDir: /var/www/html/mrtg' --global 'Options[_]: bits,growright' --output /etc/mrtg/mrtg.cfg public@

5. setup cronjob (if you install MRTG through rpm , no need, because there's a file under /etc/cron.d/mrtg already, run rpm -qil mrtg to check which are the files installed by rpm)

6. Access the serial port MRTG graphic

note: DO NOT configure cronjob for mrtg again if you install mrtg through yum install rpm command, otherwise, it will conflict, you will always receive warning email saying 'cannot rename ....' or ' cannot find primary log file...' etc