Solaris System Management Agent Developer's Guide

Managing the Timing of Data Collection

An important aspect of the demo_module_9 example is the relationship between the SNMP timeout and the delay time interval of the module. The delay time interval is the interval in seconds after which the agent sends an alarm to the module. The delay_time variable in the module stores this value. By default, the delay time is set to 1 in the module. You can change this value by issuing an snmpset command on the delayedInstanceOid object and supplying an integer value. The set_demo_module_9 script does issue the snmpset command to change the delay time interval. The new time interval value is used by the module to register for an alarm with the agent.

The agent calls the module when a snmpget or snmpset is issued on the delayedInstanceOid object. Instead of returning the requesting data right away, the module sets a flag to tell the agent that the request processing might take a while. The agent is free to handle other requests. The module then registers an alarm with the agent. The module needs some way to get the agent to return to the module and return the requested data when the data collection has completed. In demo_module_9, a one-time alarm is set to go off in 1 second. If you want a longer data collection, you can set the delay_time value to a longer interval. You can also set the alarm to go off repeatedly at a specified interval.

The module registers the alarm with a callback function. At the specific alarm interval, the agent calls the callback function in the module. In demo_module_9, the callback function is return_delayed_response(), which actually handles the SNMP GET or SNMP SET request.

The client that requested the data with SNMP GET must wait for the response from the agent. The snmpget command and other Net-SNMP tools have a default timeout value of 5 seconds. The client is likely to time out before getting the requested response. For this reason, you should increase the timeout value for the snmpget and snmpset commands.

You should increase the timeout of the command the amount of time required to complete the data collection. If you are doing an snmpset, make the timeout value 3 or 4 times longer than the delay time interval. A longer timeout is needed because a SET operation is more time-consuming than a GET. The agent makes several calls to the module to process a single SET, and each call is delayed by the delay value.

The -t option is used to set the timeout value. See thesnmpcmd(1M) man page for more information about common command-line options for Net-SNMP tools.