Setting a MIB Value

With snmpget and snmpwalk, we have retrieved management information only from devices. The next logical step is to change the value of a MIB object via SNMP. This operation is known as snmpset, or set. In this section we’ll read the value of an object, use snmpset to change its value, then read the value again to prove that it’s been changed.

There’s obviously some danger here: what happens if you change a variable that’s critical to the state of the system you’re monitoring? In this chapter, we’ll deal only with some simple objects, such as the administrative contact, that won’t damage anything if they’re changed incorrectly. Therefore, if you keep the OIDs correct, you shouldn’t worry about hurting any of your devices. All the objects we set in this chapter have an ACCESS of read-write. It’s a good idea to get a feel for which objects are writable by reading the MIB in which the object is defined -- either one of the RFCs or a MIB file provided by your vendor.

Let’s get started. Run the following OpenView command (or use one of the other programs we’ve discussed) to find out the sysContact for your chosen device:

$ /opt/OV/bin/snmpget -c public orarouter1 .1.3.6.1.2.1.1.4.0
system.sysContact.0 : DISPLAY STRING- (ascii):  ORA IT Group

The -c public switch passes the community string public to the snmpget command.

Tip

Keep in mind that your devices shouldn’t use the same (default) community strings that are used within this book. In addition, using the same string ...

Get Essential SNMP now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.