Table of ContentsView in Frames

Example: SNMP commands

You can use the snmpget, snmpwalk, snmpbulkget, and snmpbulkwalk commands to retrieve information from network elements with SNMP agents.

snmpwalk

The following command retrieves all the variables under the system sys1:
snmpwalk -Os -c public -v 1 sys1 system
sysDescr.0 = STRING: Data ONTAP Release 7.3.1 
sysObjectID.0 = OID: enterprises.789.2.3 
sysUpTimeInstance = Timeticks: (121596665) 14 days, 1:46:06.65
sysContact.0 = STRING: 
sysName.0 = STRING: sys1.lab.example.com 
sysLocation.0 = STRING: 
sysServices.0 = INTEGER: 72
The following command is an example of an SNMP request from an IPv6 client:
snmpwalk -v2c -c public udp6:[2001:0db8:85a3:0:0:8a2e:0370:99]:161 system
SNMPv2-MIB::sysDescr.0 = STRING: Data ONTAP Release 7.3.1 
SNMPv2-MIB::sysObjectID.0 = OID:
SNMPv2-SMI::enterprises.789.2.3
DISMAN-EVENT-MIB::sysUpTimeInstance = Timeticks: (11415057) 1 day,7:42:30.57
SNMPv2-MIB::sysContact.0 = STRING: 
SNMPv2-MIB::sysName.0 = STRING:n3700-183-85.sys1.lab.example.com
SNMPv2-MIB::sysLocation.0 = STRING: 
SNMPv2-MIB::sysServices.0 = INTEGER: 72
The following command is an example of an SNMPv3 request to retrieve all the variables under the system sys1:
snmpwalk -v 3 -u joe -l authNoPriv -A joe12 sys1 system
SNMPv2-MIB::sysDescr.0 = STRING: Data ONTAP Release 7.3.1
SNMPv2-MIB::sysObjectID.0 = OID:
SNMPv2-SMI::enterprises.789.2.3
DISMAN-EVENT-MIB::sysUpTimeInstance = Timeticks: (121622059) 14
days, 1:50:20.59
SNMPv2-MIB::sysContact.0 = STRING: 
SNMPv2-MIB::sysName.0 = STRING: sys1.lab.example.com
SNMPv2-MIB::sysLocation.0 = STRING: 
SNMPv2-MIB::sysServices.0 = INTEGER: 72
Note: You need to enter authentication information for using SNMPv3.

snmpget

The following command retrieves the system.sysDescr.0 object from the host sys1 by using the public community string:
snmpget -c public sys1 system.sysDescr.0
system.sysDescr.0 = Data ONTAP Release 8.0  Mon Mar 16 16:56:43 IST 2010
The following command retrieves the value of an ICMP object (OID=56.1.1.1.1) from the host sys1:
snmpget -c public -v 2c sys1 .1.3.6.1.2.1.56.1.1.1.1
    56.1.1.1.1.1 = Counter32: 0

snmpbulkget

The following command retrieves the system object sysDescr.0 and the first three objects in the ifTable:
snmpbulkget -v2c -Cn1 -Cr3 -Os -c public sys1 system ifTable 
sysDescr.0 = STRING: Data ONTAP Release 7.3.1
ifIndex.1 = INTEGER: 1
ifIndex.2 = INTEGER: 2
ifDescr.1 = STRING: "lo0"
The following example shows a part of the output from retrieving all the variables under the IPv6 object (OID=55.1):
snmpbulkget -c public -v 2c 192.0.2.19 .1.3.6.1.2.1.55.1 
    55.1.1.0 = 2
    55.1.2.0 = 64
    55.1.3.0 = Gauge32: 4
    55.1.4.0 = Counter32: 0
    55.1.5.1.1.1 = 1
    55.1.5.1.2.1 = "ns0"
    55.1.5.1.3.1 = OID: .ccitt.zeroDotZero
    55.1.5.1.4.1 = 1500
    55.1.5.1.5.1 = 65535
    55.1.5.1.6.1 = IpAddress: 00 00 00 00 00 00 00 00 02 05 00 FF FE 00 02 AB
    55.1.5.1.7.1 = 64
    55.1.5.1.8.1 =  Hex: 00 05 00 00 02 AB 
    55.1.5.1.9.1 = 1
    55.1.5.1.10.1 = 1
Note: For the snmpbulkget command, the maximum value of Cr is restricted to 100. This means that even if you provide a Cr value of more than 100, the command will fetch values only for 100 output lines. The default value for Cr is 10.

snmpbulkwalk

The following command retrieves all the variables under the system sys1:
snmpbulkwalk -v2c -Os -c public sys1 system
sysDescr.0 = STRING: Data ONTAP Release 7.3.1 
sysObjectID.0 = OID: enterprises.789.2.3 
sysUpTimeInstance = Timeticks: (121603434) 14 days, 1:47:14.34 
sysContact.0 = STRING: 
sysName.0 = STRING: sys1.lab.example.com 
sysLocation.0 = STRING: 
sysServices.0 = INTEGER: 72
The following example shows a part of the output from retrieving all the variables for the UDP object:
snmpbulkwalk -c public -v 2c 192.0.2.19 udp
    udp.udpInDatagrams.0 = Counter32: 347
    udp.udpNoPorts.0 = Counter32: 4
    udp.udpInErrors.0 = Counter32: 0
    udp.udpOutDatagrams.0 = Counter32: 138
    udp.udpTable.udpEntry.udpLocalAddress.0.0.0.0.69 = IpAddress: 00 00 00 00 
    udp.udpTable.udpEntry.udpLocalAddress.0.0.0.0.111 = IpAddress: 00 00 00 00