A P P E N D I X B |
SNMP Command Examples |
This section provides examples of how to use the following SNMP commands:
Note - All command examples given in this section are executed on the SNMP management station, unless instructions indicate otherwise. |
Before using SNMP, be sure to install the ILOM MIBs files in the directory where net-snmp tools load MIBs or where your SNMP tool of choice loads MIBs. See the following URL for additional information on net-snmp:
http://net-snmp.sourceforge.net/wiki/index.php/
TUT:Using_and_loading_MIBS
snmpget -mALL -v1 -cpublic snmp_agent_Ip_address sysName.0
As stated in the description of the sysName.0 MIB object in the SNMPv2-MIB, this command returns an administratively assigned name for this managed node. By convention, this is the node’s fully-qualified domain name. If the name is unknown, the value returned is the zero-length string.
In addition to the sysName.0 object, this command displays the content of the sysObjectID.0 and the ilomCtrlDateAndTime.0 MIB objects. Notice that the MIB file name is given for each MIB object as part of the reply.
The following descriptions of the MIB objects are taken from the MIB files.
The snmpwalk command performs a sequence of chained GETNEXT requests automatically. It is a work saving command. Rather than having to issue a series of snmpgetnext requests, one for each object ID, or node, in a sub-tree, you can simply issue one snmpwalk request on the root node of the sub-tree and the command gets the value of every node in the sub-tree.
The snmpbulkwalk command uses the GETBULK SNMP protocol feature to query for an entire tree of information about a network entity. This command can pack more objects into the packets by specifying “repeaters.” As a result, the snmpbulkwalk command is faster than the snmpwalk command.
Here is example of an snmpwalk command with approximate start and end time stamps.
% date Fri Dec 14 12:21:44 EST 2007 % snmpwalk -mALL -v2c -cprivate snmp_agent_Ip_address entPhysicalTable>time3 % date Fri Dec 14 12:21:53 EST 2007 |
Here is example of an snmpbulkwalk command performing the same operation. Notice that the snmpbulkwalk command is faster than the snmpwalk command.
% date Fri Dec 14 12:40:57 EST 2007 % snmpbulkwalk -mALL -v2c -cprivate snmp_agent_Ip_address entPhysicalTable>time7 % date Fri Dec 14 12:41:03 EST 2007 |
The snmptable command retrieves the contents of an SNMP table and displays the contents in a tabular format, that is, one table row at a time, such that the resulting output resembles the table being retrieved. This is contrasted with the snmpwalk command, which displays the contents of the table one column at a time.
Here is an example of the snmptable command:
In the examples of the snmptable command, the -Ci and -Cb options are used. For example, here is an snmptable command with the -Ci option:
% snmptable -Ci -mALL -v2c -cprivate snmp_agent_IP_address sunPlatFanTable SNMP table: SUN-PLATFORM-MIB::sunPlatFanTable index sunPlatFanClass 10 fan 11 fan 17 fan 23 fan 29 fan 30 fan 36 fan 42 fan |
Here is an example of an snmptable command without the -Ci option. Notice that the index column is not displayed:
% snmptable -mALL -v2c -cprivate snmp_agent_Ip_address sunPlatFanTable SNMP table: SUN-PLATFORM-MIB::sunPlatFanTable |
Here is an example of an snmptable command with the -Ci and -Cb options. The output is abbreviated.
% snmptable -Ci -Cb -mALL -v2c -cprivate snmp_agent_IP_address entPhysicalTable SNMP table: ENTITY-MIB::entPhysicalTable index Descr VendorType ContainedIn 1 ? SNMPv2-SMI::zeroDotZero 0 chassis |
Here is an example of the same snmptable command with the -Ci option but without the -Cb option. Again the output is abbreviated. Notice that the name of the MIB object is repeated on each heading.
Here is another example of an snmptable command with both the -Ci and -Cb options. Notice that the MIB object is not repeated on each heading.
Thus, when you used the -Cb option with the snmptable command, the table output is easier to read.
Here is an example of an snmptable command using version 3 of the SNMP protocol:
The following snmptable command returns an empty table.
% snmptable -Cb -Ci -mALL -v2c -cprivate snmp_agent_Ip_address sunPlatBatteryTable SUN-PLATFORM-MIB::sunPlatBatteryTable: No entries |
While the syntax of the snmpset command is similar to that of the snmpget command, the commands are quite different. The snmpget command merely reads the value of the specified object ID, while the snmpset command writes the value specified to the object ID. Further, along with the value to be written to the object ID, you must also specify the data type of the object ID in the snmpset command because SNMP objects support more than one data type.
The following example shows how use of the snmpget and snmpset commands together. The sequence of steps is as follows:
1. Use the snmpget command to check to current value of the MIB object.
2. Use the snmpset command to change the value of the MIB object.
3. Use the snmpget command to verify that the MIB object was in fact changed to the requested value.
Note that if you try to execute this snmpset command using a public community, instead of private, it will not work. This is because the private community has write permission, but the public community does not. The Reason code returned by the command does not make this clear because it simply states that the object is not writable.
% snmpset -mALL -v2c -cpublic snmp_agent_Ip_address ilomCtrlHttpEnabled.0 i 1 Error in packet. Reason: notWritable (That object does not support modification) |
snmptrapd is an SNMP application that receives and logs SNMP Trap and Inform messages. Before your system can receive such messages, you must configure the trap daemon to listen for these messages.
To configure a trap daemon, perform the following steps:
1. Configure an SNMP trap destination.
For an example, see Configuring an snmptrapd Daemon.
2. Start the trap receiver application, snmptrapd.
For an example, see Starting the Trap Daemon.
3. Generate a test trap to verify that traps are being sent by the agent and received by the trap receiver.
For an example, see Testing the Trap Daemon.
The following example shows how to use the snmpset command to configure an snmptrapd daemon:
The following example shows how to use the snmptrapd command start a trap daemon:
% snmptrapd -mALL -Lo -f -t -OvQ -e -F "%H.%J.%K:%W:%w %q from %A:%V,% %v\n" 2007-11-29 13:21:07 NET-SNMP version 5.2.3 Started. |
While the daemon is running, log in to the CLI on the host that is running the SNMP agent and type the following command:
-> set /SP/alertmgmt/rules testalert=true
Note - It is important to test the trap daemon to make sure it is configured properly. |
The following screen shows a sample output when a testalert trap is received:
Copyright © 2010, Oracle and/or its affiliates. All rights reserved.