How to monitor SNMP devices with MRTG

Multi Router Traffic Grapher (MRTG)The Multi Router Traffic Grapher (MRTG) is free software for monitoring and measuring the traffic load on network links. It allows the user to see traffic load on a network over time in graphical form.

1. Install MRTG

apt-get install mrtg

2. Create a config file with the cfgmaker tool by connecting to a SNMP device. cfgmaker will automatically detect the interfaces that can be monitored.

cfgmaker {community}@{ip_address} > /etc/mrtg-{device}.cfg

Set the config values:

{community} = The SNMP community, usually it’s “public” by default.
{ip_address} = host name or IP address of the device being monitored.
{device} = Some name describing the device being monitored, ex. firewall, router etc.

3. Create the working directory. If you open the config file with a text editor you can see the working directory. MRTG will store log files, html and graphs here. This should be a directory that is readable by a web server. In this example I’ll use the default, /var/www/mrtg.

mkdir /var/www/mrtg

4. Make MRTG collect data and create graphs every 5 minutes by adding a job to crontab. (crontab -e)

*/5 * * * * env LANG=C /usr/bin/mrtg /etc/mrtg-{device}.cfg

Replace {device} with the name used when you created the config file.

5. Create index file showing graphs for all interfaces of the device being monitored.

indexmaker /etc/mrtg-{device}.cfg > /var/www/mrtg/index.html

Replace {device} with the name used when you created the config file. If you changed the working directory you also need to modify it here.

6. Open the working directory in a browser, http://{ip_address}/mrtg

Replace {ip_address} with the host name or IP address of the web server. If you changed the working directory, this location may be different.

Leave a Reply

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

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>