If you have a need to have MRTG properly grab input and output usage information from network switches or routers, you need to be aware that SNMP counters for the original 32-bit counters representing this data can roll-over (circle back to zero) during the time interval between polling by MRTG. This is not a limitation of MRTG per se, but illustrates that port speeds have increased from less than 1 Mb/sec to 10 Gb/sec (or more) since SNMP was first standardized by the IETF in 1988 (RFC 1067). OIDs had to be added that use 64-bit counters to handle this. This posting describes how to do this in MRTG 2.16.

cfgmaker has logic in it that will access these larger counters, but only if you use SNMP version 2c or 3 when querying for them. To use SNMP version 2c, you add the option --snmp-options=:::::2 to the command line before the target (e.g. community@router-name) when you use cfgmaker. Please note that there are devices (like the Apple Time Capsule) which do not support the 64-bit counters, so using SNMP version 2c for them will produce a configuration that generates no results when MRTG is run. To determine how best to proceed, I run cfgmaker twice (one with the option and one without) and compare the two configuration files. I use the SNMP version 2c file when it will generate results and the SNMP version 1 file otherwise.

If you have a requirement to use SNMP version 3, the options on the command line are --enablesnmpv3 --snmp-options:::::3. You also need to specify the username of the SNMP version 3 user that is authorized to use SNMP version 3 to query the device.

Here is an example using SNMP version 3 and a Cisco Catalyst 2960 Switch running IOS 12.2(53)SE2.

  • First, insure that the switch is properly configured to answer SNMP version 3 queries. For this example, no authentication will be used. Here are the IOS command to setup SNMP version 3 on the switch.

  • snmp-server group mrtggroup v3
    snmp-server user mrtguser mrtggroup v3

  • Next, use cfgmaker to generate the mrtg configuration file.

  • cfgmaker --enablesnmpv3 --snmpoptions=:::::3 -username mrtguser switch-hostname > switch-hostname.cfg

The configuration file generated when used by MRTG will query the switch using SNMP version 3 retrieving data from the 64-bit counters.

I want to thank Jeff Chandler for commenting about MRTG and SNMP version 3 on another post. It made me curious enough to figure it out and write it up for this posting.