Solaris System Management Agent Developer's Guide

Multiple SET Processing in demo_module_2

The demo_module_2 example code shows how to perform a multiple OID set action. In this case, a file name and row status are provided.

When the agent processes a SET request, a series of calls to the MIB module code are made. These calls ensure that all SET requests in the incoming packet can be processed successfully. This processing allows modules the chance to get out of the transaction sequence early. If the module gets out of one transaction early, none of the transactions in the set are completed, in order to maintain continuity. However, this behavior makes the code for processing SET requests more complex. The following diagram is a simple state diagram that shows each step of the master agent's SET processing.

Figure 3–1 Set Processing State Diagram

State diagram shows each
step of the master agent's set processing.

An operation with no failures is illustrated by the vertical path on the left, in the preceding figure. If any of the MIB modules that are being acted upon returns an error, the agent branches to one of the failure states. The failure states are on the right side in the figure. These failure states require you to clean up and, where necessary, undo the actions of previous steps in your module.

See the me1FileTable_handler() function in the demo_module_2 example code, for how to perform SET requests in different states. The following is list describes each of the states:

case MODE_SET_RESERVE1

Checks that the value being set is acceptable.

case MODE_SET_RESERVE2

Allocates any necessary resources. For example, calls to the malloc() function occur here.

case MODE_SET_FREE

Frees resources when one of the other values being SET failed for some reason.

case MODE_SET_ACTION

Sets the variable as requested and saves information that might be needed in order to reverse this SET later.

case MODE_SET_COMMIT

Operation is successful. Discards saved information and makes the change permanent. For example, writes to the snmpd.conf configuration file and frees any allocated resources.

case MODE_SET_UNDO

A failure occurred, so resets the variable to its previous value. Frees any allocated resources.

You can perform the set action using either of the following commands when you use the demo_module_2 example:


snmpset -v1 -c private localhost me1FileTable.1.2.3 s "test"

snmpset -v1 -c private localhost .1.3.6.1.4.1.42.2.2.4.4.1.2.1.1.2.2 s "test"

These commands change the file that you want to monitor.


Note –

In order to use the snmpset command to specify a different file name, you must have a private community string in the snmpd.conf file, which is located in /etc/sma/snmp or $HOME/.snmp.