snmpnetstat NET SNMP UCD SNMP

139 MAX-ACCESS read-write STATUS current DESCRIPTION The textual identification of the contact person for this managed node, together with information on how to contact this person. If no contact information is known, the value is the zero-length string. ::= { iso1 org3 dod6 internet1 mgmt2 mib-21 system1 4 } This is basically what we saw in the MIB but in a little more detail. By the way, the lines starting with — are just comments embedded in the MIB. We can use snmptranslate to generate a tree representation for subtrees by using the -Tp option. For example: bsd4 snmptranslate -Tp system +--system1 | +-- -R-- String sysDescr1 | Textual Convention: DisplayString | Size: 0..255 +-- -R-- ObjID sysObjectID2 +-- -R-- TimeTicks sysUpTime3 +-- -RW- String sysContact4 | Textual Convention: DisplayString | Size: 0..255 +-- -RW- String sysName5 | Textual Convention: DisplayString | Size: 0..255 +-- -RW- String sysLocation6 | Textual Convention: DisplayString | Size: 0..255 +-- -R-- Integer sysServices7 +-- -R-- TimeTicks sysORLastChange8 | Textual Convention: TimeStamp | +--sysORTable9 | +--sysOREntry1 | +-- ---- Integer sysORIndex1 +-- -R-- ObjID sysORID2 +-- -R-- String sysORDescr3 | Textual Convention: DisplayString | Size: 0..255 +-- -R-- TimeTicks sysORUpTime4 Textual Convention: TimeStamp Dont forget the final argument or youll get the entire MIB. There are also options to print all objects in labeled form -Tl , numeric form -To, or symbolic form -Tt, but frankly, Ive never found much use for these. These options simply give too much data. One last word of warning: if you have trouble using snmptranslate, the first thing to check is whether your MIBs are correctly loaded.

7.2.1.6 snmpnetstat

snmpnetstat is an SNMP analog to netstat. Using SNMP, it will provide netstat-like information from remote systems. Many of the major options are the same as with netstat. A few examples will show how this tool is used. 140 The -an option will show the sockets in open mode: bsd4 snmpnetstat 172.16.2.234 public -an Active Internet tcp Connections including servers Proto Local Address Foreign Address state tcp .ftp . LISTEN tcp .telnet . LISTEN tcp .smtp . LISTEN tcp .http . LISTEN tcp .sunrpc . LISTEN tcp .printer . LISTEN tcp .659 . LISTEN tcp .680 . LISTEN tcp .685 . LISTEN tcp .690 . LISTEN tcp .1024 . LISTEN tcp 172.16.2.234.telnet sloan.1135 ESTABLISHED Active Internet udp Connections Proto Local Address udp .sunrpc udp .snmp udp .who udp .657 udp .668 udp .678 udp .683 udp .688 udp .1024 udp .nfsd Notice that with snmpnetstat, the options are listed at the end of the command. The -r option gives the route table. Here is a route table from a Cisco 3620 router: bsd4 snmpnetstat 172.16.2.1 public -rn Routing tables Destination Gateway Flags Interface default 205.153.60.2 UG if0 172.16.124 172.16.1.1 U Ethernet01 172.16.224 172.16.2.1 U Ethernet02 172.16.324 172.16.3.1 U Ethernet03 205.153.60 205.153.60.250 U Ethernet00 205.153.61 205.153.60.1 UG if0 205.153.62 205.153.60.1 UG if0 205.153.63 205.153.60.1 UG if0 In each of these examples, the -n option is used to suppress name resolution. Here are the packet counts for the interfaces from the same router: bsd4 snmpnetstat 172.16.2.1 public -i Name Mtu Network Address Ipkts Ierrs Opkts Oerrs Queue Ethernet01 1500 172.16.124 172.16.1.1 219805 0 103373 0 0 Ethernet00 1500 205.153.60 205.153.60.250 406485 0 194035 0 0 Ethernet02 1500 172.16.224 172.16.2.1 177489 1 231011 0 0 Ethernet03 1500 172.16.324 172.16.3.1 18175 0 97954 0 0 Null0 1500 0 0 0 0 0 As with netstat, the -i option is used. 141 As a final example, the -s option is used with the -P option to get general statistics with output restricted to a single protocol, in this case IP: bsd4 snmpnetstat 172.16.2.1 public -s -P ip ip: 533220 total datagrams received 0 datagrams with header errors 0 datagrams with an invalid destination address 231583 datagrams forwarded 0 datagrams with unknown protocol 0 datagrams discarded 301288 datagrams delivered 9924 output datagram requests 67 output datagrams discarded 4 datagrams with no route 0 fragments received 0 datagrams reassembled 0 reassembly failures 0 datagrams fragmented 0 fragmentation failures 0 fragments created This should all seem very familiar to netstat users.

7.2.1.7 snmpstatus