snmpset snmptranslate NET SNMP UCD SNMP

137 local 33 255.255.255.0 -1 .ccitt.nullOID Even with snmptable, it can be a little tricky to get readable output. In this case, I have used two options to help. -Cb specifies a brief header. -Cw 80 defines a maximum column width of 80 characters, resulting in a multipart table. You can also specify the column delimiter with the -Cf option, and you can suppress headers altogether with the -CH option. There are also a snmpbulkget and a snmpbulkwalk if you are using SNMPv2.

7.2.1.4 snmpset

The snmpset command is used to change the value of objects by sending SET_REQUEST messages. The syntax of this command is a little different from previous commands since you must also specify a value and a type for the value. You will also need to use a community string that provides readwrite access: bsd4 snmpset 172.16.1.5 private sysContact.0 s el Zorro system.sysContact.0 = el Zorro In this example, the system contact was set using a quote-delimited string. Legitimate types include integers i, strings s, hex strings x, decimal strings d, null objects n, object ID o, time ticks t, and IP addresses a, among others. People often think of SNMP as being appropriate only for collecting information, not as a general configuration tool, since SNMP only allows objects to be retrieved or set. However, many objects are configuration parameters that control the operation of the system. Moreover, agents can react to changes made to objects by running scripts, and so on. With the appropriate agent, virtually any action can be taken. [2] For example, you could change entries in an IP routing table, enable or disable a second interface on a device, or enable or disable IP forwarding. With an SNMP-controlled UPS, you could shut off power to a device. What you can do, and will want to do, will depend on both the device and the context. You will need to study the documentation for the device and the applicable MIBs to know what is possible on a case-by-case basis. [2] In an extremely interesting interview of John Romkey by Carl Malamud on this topic, Romkey describes an SNMP-controlled toaster. The interview was originally on the Internet radio program Geek of the Week May 29, 1993. At one time, it was available on audio tape from OReilly Associates ISBN 1-56592-997-7. Visit http:town.hall.orgradioGeek and follow the link to Romkey.

7.2.1.5 snmptranslate

In all the preceding examples, I have specified an OID. An obvious question is how did I know the OID? Available OIDs are determined by the design of the agent and are described by its MIB. There are several different approaches you can take to discover the contents of a MIB. The most direct approach is to read the MIB. This is not a difficult task if you dont insist on understanding every detail. Youll be primarily interested in the object definitions. Here is an example of the definition of the system contact sysContact taken from MIB-II RFC 1213: sysContact OBJECT-TYPE SYNTAX DisplayString SIZE 0..255 ACCESS read-write STATUS mandatory DESCRIPTION 138 The textual identification of the contact person for this managed node, together with information on how to contact this person. ::= { system 4 } The object name is in the first line. The next line says the objects type is a string and specifies its maximum size. The third line tells us that this can be read or written. In addition to read-write, an object may be designated read-only or not-accessible. While some objects may not be implemented in every agent, this object is required, as shown in the next line. Next comes the description. The last line tells where the object fits into the MIB tree. This is the fourth node in the system group. With an enterprise MIB, there is usually some additional documentation that explains what is available. With standard MIBs like this one, numerous descriptions in books on SNMP describe each value in detail. These can be very helpful since they are usually accompanied by tables or diagrams that can be scanned quickly. See Appendix B for specific suggestions. NET SNMP provides two tools that can be helpful. We have already discussed snmpwalk. Another useful tool is snmptranslate. This command is designed to present a MIB in a human-readable form. snmptranslate can be used in a number of different ways. First, it can be used to translate between the text and numeric form of an object. For example: bsd4 snmptranslate system.sysContact.0 .1.3.6.1.2.1.1.4.0 We can get the numeric form with the -On option as shown in the next two examples: bsd4 snmptranslate -On .1.3.6.1.2.1.1.4.0 system.sysContact.0 bsd4 snmptranslate -Ofn system.sysContact.0 .iso.org.dod.internet.mgmt.mib-2.system.sysContact.0 snmptranslate can be a little particular about prefixes. In the previous example, sysContact.0 would not have been sufficient. You can get around this with the -IR option. This is usually the default for most NET SNMP commands. bsd4 snmptranslate -IR sysContact.0 .1.3.6.1.2.1.1.4.0 You can also use regular expression matching. For example: bsd4 snmptranslate -On -Ib sys.ime system.sysUpTime Notice the use of single quotes. This option can return a few surprises at times as well. You get extended information by using the -Td option: bsd4 snmptranslate -Td system.sysContact .1.3.6.1.2.1.1.4 sysContact OBJECT-TYPE —FROM SNMPv2-MIB, RFC1213-MIB -- TEXTUAL CONVENTION DisplayString SYNTAX OCTET STRING 0..255 DISPLAY-HINT 255a 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