snmpget NET SNMP UCD SNMP

132 of managed objects is by experimentation, and that requires tools. I will try to clarify some of these concepts as we examine SNMP management tools.

7.2 SNMP-Based Management Tools

There are several extremely powerful and useful noncommercial SNMP tools. Tools from the NET SNMP project, scotty, and tkined are described here.

7.2.1 NET SNMP UCD SNMP

The University of California at Davis implementation of SNMP UCD SNMP has its origin in a similar project at Carnegie Mellon University under Steve Waldbusser CMU SNMP. In the mid- nineties, the CMU project languished. During this period, the UCD project was born. The UCD project has greatly expanded the original CMU work and is flourishing, thanks to the work of Wes Hardaker. The CMU project reemerged for a while with a somewhat different focus and has seen a lot of support in the Linux community. Both are excellent. While only UCD SNMP will be described here, the basics of each are so similar that you should have no problem using CMU SNMP once you are familiar with UCD SNMP. Very recently, UCD SNMP has been renamed NET SNMP to reflect some organizational changes. NET SNMP is actually a set of tools, a SNMP library, and an extensible agent. The source code is available and runs on a number of systems. Binaries are also available for some systems, including Microsoft Windows. NET SNMP supports SNMPv1, SNMPv2c, and SNMPv3. Admittedly, the NET SNMP toolset is not ideal for the routine management of a large network. But it is ideal for learning about SNMP, is not an unreasonable toolset for occasional tasks on smaller networks, and can be particularly useful in debugging SNMP problems, in part because it separates SNMP functions into individual utilities. The agent software is a logical choice for systems using Linux or FreeBSD and is extensible. Most, but not all, of the utilities will be described.

7.2.1.1 snmpget

In the last section, it was stated that there are three messages that can be sent by a management station: GET_REQUEST, GET_NEXT_REQUEST, and SET_REQUEST. NET SNMP provides utilities to send each of these messages—snmpget, snmpgetnext, and snmpset, respectively. In order to retrieve the value of an object, it is necessary to specify the name or IP address of the remote host, a community string for the host, and the OID of the object. For example: bsd4 snmpget 172.16.1.5 public .1.3.6.1.2.1.1.1.0 system.sysDescr.0 = APC Embedded PowerNet SNMP Agent SW v2.2, HW vB2, Mod: AP9 605, Mfg 081096, SN: WA9632270847, Agent Loader v1.0 There are a couple of points to make about the OID. First, notice the at the end. This is an offset into the data. It is a common error to omit this. If you are looking at a table, you would use the actual offset into the table instead of a . For example, the description of the third interface in the interface table would have the OID ifDescr.3 . 133 Second, the leading dot is important. NET SNMP will attempt to attach a prefix to any OIDs not beginning with a dot. By default, the prefix is 1.3.6.1.2.1 , but you can change this by setting the environment variable PREFIX. In this example, we have specified the OID explicitly. Without the leading dot, snmpget would have added the prefix to what we had, giving an OID that was too long. On the other hand, you could just use 1.1.0 without the leading dot and you would get the same results. Initially, using the prefix can be confusing, but it can save a lot of typing once you are used to it. Of course, you can also use names rather than numbers, provided the appropriate MIB is available. This is shown in the next two examples: bsd4 snmpget 172.16.1.5 public iso.org.dod.internet.mgmt.mib- 2.system.sysDescr.0 system.sysDescr.0 = APC Embedded PowerNet SNMP Agent SW v2.2, HW vB2, Mod: AP9 605, Mfg 081096, SN: WA9632270847, Agent Loader v1.0 bsd4 snmpget 172.16.1.5 public system.sysDescr.0 system.sysDescr.0 = APC Embedded PowerNet SNMP Agent SW v2.2, HW vB2, Mod: AP9 605, Mfg 081096, SN: WA9632270847, Agent Loader v1.0 In the first case, the full path was given, and in the second the prefix was used. Dont forget the trailing . Numbers and names can be mixed: bsd4 snmpget 172.16.1.5 public .1.3.6.internet.2.1.system.1.0 system.sysDescr.0 = APC Embedded PowerNet SNMP Agent SW v2.2, HW vB2, Mod: AP9 605, Mfg 081096, SN: WA9632270847, Agent Loader v1.0 Frankly, I cant see much reason for doing this. Also, if the MIB is known, you can do a random-access lookup for unique node names: bsd4 snmpget 172.16.1.5 public upsBasicIdentModel.0 enterprises.apc.products.hardware.ups.upsIdent.upsBasicIdent.upsBasicIdentModel. 0 = APC Smart-UPS 700 In this example, only the final identifier in the OID, upsBasicIdentMode.0 , is given, and the MIB is searched to construct the full OID. This can be particularly helpful if you want to query several objects with a single snmpget. You can also use multiple OIDs in the same snmpget command to retrieve the values of several objects.

7.2.1.2 Configuration and options