intERLab AIT March 2008
Network Management Workshop
MRTG / RRD Tool
MRTG
In 12 Steps
1. Install MRTG
# apt-get install mrtg
2. Create the /etc/mrtg directory
$ sudo mkdir /etc/mrtg
3. Find out the SNMP Community String – 1nterl4b
4. Find the IP / name of the Device
- 10.10.10.1
- or one of the other routers and switches (10.10.10.10, 10.10.1.253, 10.10.1.254, 10.10.2.253, 10.10.2.254)
5. Run cfgmaker (the command below all on one line!)
# /usr/bin/cfgmaker --output=/etc/mrtg/router.mrtg --global 'workdir: /var/www/mrtg'
--global 'options[_]: growright,bits' 1nterl4b@10.10.?.?
Make the workdir if necessary:
# mkdir -p /var/www/mrtg/
6. View the mrtg configuration file created by cfgmaker, you can make changes and see the results, if you want (/etc/mrtg/router.mrtg)
7. Use indexmaker to create HTML files
# /usr/bin/indexmaker --output=/var/www/mrtg/device.html /etc/mrtg/router.mrtg
8. Run MRTG command (ignore the error and run 3 times)
# /usr/bin/mrtg /etc/mrtg/router.mrtg
9. put the above command in a script
# echo '/usr/bin/mrtg /etc/mrtg/router.mrtg' > /etc/mrtg/mrtgscript
# chmod +x /etc/mrtg/mrtgscript
NOTE: on systems with UTF-8 as the default locale, this will cause problems – you need to explicitly specify: 'env LANG=C /usr/bin/mrtg /etc/mrtg/router.mrtg' when running the script.
10. Edit the crontab and insert the command to be run every 5 minutes
# crontab -e
0-59/5 * * * * /etc/mrtg/mrtgscript
11. Load the browser through webserver
http://localhost/mrtg/
12. Go for Tea / come back and see if your graph is moving.
RRDTool
# apt-get install rrdtool
# apt-get install librrdp-perl
# apt-get install librrds-perl
Add in your MRTG Configuration file
# vi /etc/mrtg/router.mrtg
; add below Workdir
LogFormat: rrdtool
[ go to /var/www/mrtg/ and see how the .rrd files have been created]
What about graphs ?
1. Install mrtg-rrd
# apt-get install mrtg-rrd
# cd /usr/lib/cgi-bin
# ln -s mrtg-rrd.cgi 14all.cgi
2. rerun indexmaker
# /usr/bin/indexmaker --output=/var/www/mrtg/device.html /etc/mrtg/router.mrtg
3. Create
/etc/mrtg-rrd.conf like this:
# echo '/etc/mrtg/router.mrtg'
>/etc/mrtg-rrd.conf
4. Make
/var/www/mrtg writeable for the Web server:
# chown www-data
/var/www/mrtg
Look at the webpage (http://localhost/mrtg/router.html) again!