{"id":1607,"date":"2018-08-02T13:44:23","date_gmt":"2018-08-02T12:44:23","guid":{"rendered":"https:\/\/www.lightsoftai.com\/?p=1607"},"modified":"2018-08-02T13:44:23","modified_gmt":"2018-08-02T12:44:23","slug":"mrtg-snmpwalk-and-snmpget","status":"publish","type":"post","link":"https:\/\/www.lightsoftai.com\/?p=1607","title":{"rendered":"Mrtg snmpwalk and snmpget"},"content":{"rendered":"<p>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.<\/p>\n<p>Preconditions:<\/p>\n<p>Router at IP: 192.168.0.1, we name it FVS338. We have access to it by using the community: &#8220;public&#8221;.<\/p>\n<p>One way if we don&#8217;t know the services supported by the router we can list everything and then take what we need.<br \/>\n<code lang=\"bash\">snmpwalk -c public -v 1 192.168.0.1 .1<\/code><\/p>\n<p>I for example thought this was interesting.<br \/>\n<code lang=\"bash\"><br \/>\nIF-MIB::ifOutOctets.1 = Counter32: 96463214<br \/>\nIF-MIB::ifOutOctets.2 = Counter32: 0<br \/>\nIF-MIB::ifOutOctets.3 = Counter32: 2549561770<br \/>\nIF-MIB::ifOutOctets.4 = Counter32: 3927692041<br \/>\n<\/code><\/p>\n<p>By using the MIB&#8217;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.<br \/>\n<br \/>\n<code><br \/>\nOID value: 1.3.6.1.2.1.2.2.1.16<br \/>\n<\/code><br \/>\n<br \/>\nOID description:<br \/>\n<code lang=\"html\"><br \/>\nifOutOctets OBJECT-TYPE<br \/>\n              SYNTAX  Counter<br \/>\n              ACCESS  read-only<br \/>\n              STATUS  mandatory<br \/>\n              DESCRIPTION<br \/>\n                      \"The total number of octets transmitted out of the<br \/>\n                      interface, including framing characters.\"<br \/>\n              ::= { ifEntry 16 }<br \/>\n<\/code><\/p>\n<p>At the router i have another .3 I have to add, since this have 4 network ports. The port 3 is for my WAN.<\/p>\n<p>OID value is another way to put the actual path in the structure where this SNMP value is.<\/p>\n<p>So my whould be:<br \/>\n<code lang=\"html\"><br \/>\nOID: 1.3.6.1.2.1.2.2.1.16.3 or ifOutOctets.3<br \/>\n<\/code><\/p>\n<p><!--adsense--><\/p>\n<p>Now we have to check that it is possible to use snmpget since this is what MRTG uses.<br \/>\n<code lang=\"bash\"><br \/>\nsnmpget -c public -v 1 192.168.0.1 ifOutOctets.3<br \/>\nIF-MIB::ifOutOctets.3 = Counter32: 2550004051<br \/>\n<\/code><\/p>\n<p>Since we didn&#8217;t get any error, and see the value, this should be working. Now add it to the mrtg.cfg file:<br \/>\n(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.<\/p>\n<p><code lang=\"php\"><br \/>\nTarget[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<br \/>\n<\/code><\/p>\n<p>Don&#8217;t forget to add the TCP-MIB in your configuration aswell, an example:<\/p>\n<p><code><br \/>\nLoadMIBs: \/usr\/share\/snmp\/mibs\/UCD-SNMP-MIB.txt,\/usr\/share\/snmp\/mibs\/TCP-MIB.txt<br \/>\n<\/code><\/p>\n<p>The complete configurations could look like:<\/p>\n<p><code lang=\"php\"><br \/>\nLoadMIBs: \/usr\/share\/snmp\/mibs\/UCD-SNMP-MIB.txt,\/usr\/share\/snmp\/mibs\/TCP-MIB.txt<br \/>\nTarget[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<br \/>\nTitle[router.traffic]: Traffic Load on Router<br \/>\nPageTop[router.traffic]: <H1>Traffic Load on Router<\/H1><br \/>\nMaxBytes[router.traffic]: 10250000<br \/>\nShortLegend[router.traffic]: Bytes<br \/>\nYLegend[router.traffic]: Traffic Load<br \/>\nLegend1[router.traffic]: Current Traffic load<br \/>\nLegendI[router.traffic]: In<br \/>\nLegendO[router.traffic]: Out<br \/>\nOptions[router.traffic]: growright<br \/>\n#Unscaled[router.traffic]: ymwd<br \/>\n#Suppress[router.traffic]: my<br \/>\n<\/code><\/p>\n","protected":false},"excerpt":{"rendered":"<p>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: &#8220;public&#8221;. [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[5],"tags":[84,82,85],"class_list":["post-1607","post","type-post","status-publish","format-standard","hentry","category-coding","tag-mib","tag-mrtg","tag-snmp"],"_links":{"self":[{"href":"https:\/\/www.lightsoftai.com\/index.php?rest_route=\/wp\/v2\/posts\/1607","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.lightsoftai.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.lightsoftai.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.lightsoftai.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.lightsoftai.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=1607"}],"version-history":[{"count":1,"href":"https:\/\/www.lightsoftai.com\/index.php?rest_route=\/wp\/v2\/posts\/1607\/revisions"}],"predecessor-version":[{"id":1608,"href":"https:\/\/www.lightsoftai.com\/index.php?rest_route=\/wp\/v2\/posts\/1607\/revisions\/1608"}],"wp:attachment":[{"href":"https:\/\/www.lightsoftai.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=1607"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.lightsoftai.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=1607"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.lightsoftai.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=1607"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}