Coding

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.

Preconditions:

Router at IP: 192.168.0.1, 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 192.168.0.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: 1.3.6.1.2.1.2.2.1.16


OID description:

ifOutOctets OBJECT-TYPE
SYNTAX Counter
ACCESS read-only
STATUS mandatory
DESCRIPTION
"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: 1.3.6.1.2.1.2.2.1.16.3 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 192.168.0.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: 1.3.6.1.2.1.2.2.1.10 which means that there is 2 values added to the mrtg.


Target[router.traffic]: 1.3.6.1.2.1.2.2.1.16.3&1.3.6.1.2.1.2.2.1.10.3:public@192.168.0.1

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
Target[router.traffic]: 1.3.6.1.2.1.2.2.1.16.3&1.3.6.1.2.1.2.2.1.10.3:public@192.168.0.1
Title[router.traffic]: Traffic Load on Router
PageTop[router.traffic]:

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.