Mrtg snmpwalk and snmpget

It is not always possible to know there the interesting data is on a router and this whould take up an example of how to gather the trafficflow thru the router, by using snmpwalk and snmpget.


Router at IP:, we name it FVS338. We have access to it by using the community: “public”.

One way if we don’t know the services supported by the router we can list everything and then take what we need.
snmpwalk -c public -v 1 .1

I for example thought this was interesting.

IF-MIB::ifOutOctets.1 = Counter32: 96463214
IF-MIB::ifOutOctets.2 = Counter32: 0
IF-MIB::ifOutOctets.3 = Counter32: 2549561770
IF-MIB::ifOutOctets.4 = Counter32: 3927692041

By using the MIB’s found on the internet (this was the TCP-MIB, usaly found in linux: /usr/share/snmp/mibs/TCP-MIB.txt), I can see that this gives the outTraffic.

OID value:

OID description:

SYNTAX Counter
ACCESS read-only
STATUS mandatory
"The total number of octets transmitted out of the
interface, including framing characters."
::= { ifEntry 16 }

At the router i have another .3 I have to add, since this have 4 network ports. The port 3 is for my WAN.

OID value is another way to put the actual path in the structure where this SNMP value is.

So my whould be:

OID: or ifOutOctets.3

Now we have to check that it is possible to use snmpget since this is what MRTG uses.

snmpget -c public -v 1 ifOutOctets.3
IF-MIB::ifOutOctets.3 = Counter32: 2550004051

Since we didn’t get any error, and see the value, this should be working. Now add it to the mrtg.cfg file:
(I also used the inTraffic for the WAN port named: which means that there is 2 values added to the mrtg.


Don’t forget to add the TCP-MIB in your configuration aswell, an example:

LoadMIBs: /usr/share/snmp/mibs/UCD-SNMP-MIB.txt,/usr/share/snmp/mibs/TCP-MIB.txt

The complete configurations could look like:

LoadMIBs: /usr/share/snmp/mibs/UCD-SNMP-MIB.txt,/usr/share/snmp/mibs/TCP-MIB.txt
Title[router.traffic]: Traffic Load on Router

Traffic Load on Router

MaxBytes[router.traffic]: 10250000
ShortLegend[router.traffic]: Bytes
YLegend[router.traffic]: Traffic Load
Legend1[router.traffic]: Current Traffic load
LegendI[router.traffic]: In
LegendO[router.traffic]: Out
Options[router.traffic]: growright
#Unscaled[router.traffic]: ymwd
#Suppress[router.traffic]: my

Leave a Reply

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