PacNOG 5, Papeete, French Polynesia

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 – pacn0g2k9


4. Find the IP / name of the Device

- 192.168.1.X (one of the routers and switches (.221, .222, .223)


5. Run cfgmaker (the command below all on one line!)


# /usr/bin/cfgmaker --output=/etc/mrtg/device.mrtg --global 'workdir: /var/www/mrtg' --global 'options[_]: growright,bits' pacn0g2k9@192.168.1.X


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/device.mrtg)


7. Use indexmaker to create HTML files (all on one line!)

# /usr/bin/indexmaker --output=/var/www/mrtg/device.html /etc/mrtg/device.mrtg


8. Run MRTG command (ignore the error and run 3 times)

# /usr/bin/mrtg /etc/mrtg/device.mrtg


NOTE: Ubuntu/Debian will probably complain about LANG at this point. If this is so, just run

the command below as LANG=C /usr/bin/mrtg /etc/mrtg/device.mrtg”


9. put the above command in a script

# echo 'LANG=C /usr/bin/mrtg /etc/mrtg/device.mrtg' >/etc/mrtg/mrtgscript

# chmod +x /etc/mrtg/mrtgscript



10. Edit the crontab and insert the command to be run every 5 minutes


# crontab -e


add:


0-59/5 * * * * /etc/mrtg/mrtgscript


11. Load the browser through webserver


http://localhost/mrtg/device.html


12. Go for Tea /come back and see if your graph is moving (wait at LEAST 10 minutes!)


RRDTool


# apt-get install rrdtool

# apt-get install librrdp-perl

# apt-get install librrds-perl



Add in your MRTG Configuration file


# vi /etc/mrtg/device.mrtg


; add below Workdir

LogFormat: rrdtool


[ go to /var/www/mrtg/ and see how the .rrd files have been created ]


But 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/device.mrtg


3. Create /etc/mrtg-rrd.conf like this:

# echo '/etc/mrtg/device.mrtg' >/etc/mrtg-rrd.conf


4. Make /var/www/mrtg writeable for the Web server:

# chown www-data /var/www/mrtg


5. Remove the old PNG files for the MRTG graphs:


# rm /var/www/mrtg/192*png


6. Look at the webpage (http://localhost/mrtg/device.html) again!


Notice: