Systems and Network Management SNMP Operations 1 Background The Net-snmp tools are useful particularly since they implement aspects of the protocol in a simple, understandable way, and are ideal for learning about the snmp protocol. They are also useful troubleshooting tools. The tool snmpget implements the get-request part of the snmp protocol. Read the man page for snmpcmd and make sure you understand what you are doing. 1.1 The get-request Operation get manager (NMS) response agent device Figure 1: A manager sends an snmp get-request to an agent, which sends a response to the manager. Figure 1 shows a manager sending an snmp get-request to an agent running on a managed network device, such as a network switch or network server. The get-request contains one or more oids. The agent responds by sending back the data associated with each oid. 1.2 Instance Numbers Managed objects come in two main types: • scalars, and • tables. The oid of each managed object ends with an instance number. The instance number is zero for a scalar, and is equal to the index for a table entry. We will look at snmp tables in detail later. The instance numbers for table entries start from the value 1. 2 Procedure 1. The snmpget command can be used to retrieve data from a remote host given its host name, authentication information and an oid. As a simple example: Nick Urbanik ver. 1.3 SNMP Operations Systems and Network Management 2 $ snmpget -v 1 -c public ictlab.tyict.vtc.edu.hk system.sysUpTime.0 In the above example, ictlab.tyict.vtc.edu.hk is the host name we wanted to talk to, using the snmp community string public and we requested the value of the oid system.sysUpTime.0, using snmp protocol version 1. 2. We used snmpv1 here. snmpv2c, which is similar in nature to snmpv1 with small modifications, still uses clear-text community names as “passwords” to authenticate the sender of the command. The result from a command using the snmpv2c version is the same: $ snmpget -v 2c -c public ictlab.tyict.vtc.edu.hk system.sysUpTime.0 3. All of the utilities allow abbreviation of the oids and do random searches by default, (like snmptranslate with its -IR option), and so if you like, you can specify a small part of the oid: $ snmpget -v 2c -c public ictlab.tyict.vtc.edu.hk sysUpTime.0 4. A common mistake when using the snmpget command is to leave off the instance number of the data you’re looking for. See section 1.2 on the page before. In the above commands, the variable requested by the oid is a scalar and the instance number for scalars is always a simple ‘0’ (zero), hence the trailing ‘.0’ in all the oids above. If you had left it off, you would have gotten an error. Note that the errrors differ slightly between snmpv1 and snmpv2c: $ snmpget -v 1 -c public ictlab.tyict.vtc.edu.hk sysUpTime Error in packet Reason: (noSuchName) There is no such variable name in this MIB. Failed object: system.sysUpTime $ snmpget -v 2c -c public ictlab.tyict.vtc.edu.hk sysUpTime system.sysUpTime = No Such Instance currently exists 5. Multiple variables can be retrieved in one transaction as well: $ snmpget -v 2c -c public ictlab.tyict.vtc.edu.hk sysUpTime.0 sysContact.0 6. Do you think that the tool snmpget functions in the role of an agent or in the role of a manager ? 7. Now use snmptranslate -Tp and the documentation for the tools in the software package net-snmp-utils to determine the load average on ictlab.tyict.vtc.edu.hk. Compare the readings you get with: $ ssh ictlab uptime 10:01am up 14 days, 26 min, 9 users, load average: 0.29, 0.24, 0.16 Hint: try piping the output of snmptranslate -Tp through grep -i load. The option -C5 to grep may help. This prints 5 lines before and after the matching line. Nick Urbanik ver. 1.3