MRTG in Minutes!

MRTG is one of those tools a Network Engineer has on his/her toolbelt. MRTG allows the graphing of trending network activity for a wide range of devices. It uses SNMP to query a host and poll it’s network information and statistics. It can be used with Routers, Switches, Linux Hosts, etc.

I’m going to run MRTG against a Linux Router(running IPtables), a HP PowerConnect Switch, a Cisco Router, and an ESXi host. Anyway….Let’s get started.

Prepare SNMP Devices

  • Linux Router –Install SNMPd on the Linux Host being used as a router.

    What we are doing here is setting up the default settings for SNMPd. local is the Read/Write group profile, which will only be localhost. mynetwork is the Read Only group profile, which will be accessable by any host address on the

  • PowerConnect Switch

    Note:We are setting the snmp server IP and the community string of public to Read Only.This way when MRTG trys to query SNMP statistics it will have permissions to read the Switch’s metrics.

  • Cisco Switch/Router

    Very similar to PowerConnect Switch

  • ESXi 5.1 Host

    1. Get the current Community

      Notice, SNMP is currently not enabled. So we need to enable it :-p

    2. Enable SNMP

      This will configure the ESXi host to use community public and trust

Setting up the MRTG Collector

  1. First off, install MRTG:

  2. Create a MRTG config for each Device

    Run the cfgmaker command to auto populate the cfg for this type of host. This will create a config file for this device type….

    We assume is our Router

  3. Create an Index.html page for each Device

    Notice, The indexmaker reads the MRTG config file that you made above and creates HTML to present the graphs for each interface.

  4. Configure CRON job to periodically poll each Device

  5. Notice, the above line sets a cron job to run every 5 minutes and run MRTG using configuration file router.cfg. So if you have multiple devices, just add a new line for each one.


Leave a Reply