Solaris System Management Agent Developer's Guide

SNMP Manager Polling Method for Data Collection

In the SNMP manager polling method, an SNMP manager polls a status variable to find out whether a data collection is complete. When the data collection is complete, the age of the data is determined. If the date of the data is not acceptable, the manager can set the status variable to start a new collection. The polling method is recommended if you have one SNMP manager that is to control the polling of one or more agents. The demo_module_10 example demonstrates the SNMP manager polling approach.

demo_module_10 Code Example for SNMP Polling Method

The demo_module_10 code is located by default in /usr/demo/sma_snmp/demo_module_10. The README_demo_module_10 file within that directory contains instructions that tell how to perform the following tasks:

The demo_module_10 example implements the objects defined in the SDK-DEMO10-MIB.txt. The module is designed to handle long-running data collections so that their values can be polled by an SNMP manager. The module also shows how to implement objects that normally would block the agent as the agent waits for external events. The agent can continue responding to other requests while this implementation waits.

The demo_module_10 module uses the following features:

Avoiding a Race Condition When Polling

A race condition can occur with two or more management applications. When multiple applications issue GET or SET protocol operations that span more than a single PDU, competition for the results occurs. In the case of a long-running data collection, a race condition can occur when the module completes data collection. The module updates the status variable to indicate that the data is ready to send. However, the agent issues a second GET operation on the same variable before the first request receives the requested data. If the module starts a new data collection in response to the second request, no data is available to return to the first request.

In the following figure, Mgr2's request is received by the module after Mgr1's request but before Mgr1 gets the data. This situation could happen if the module starts a new data collection while requests are pending.

Figure 8–1 Race Condition When Polling for Data

Diagram shows two managers
polling for same data

To avoid this scenario, a module can define a flag to maintain the state of outstanding requests. When an SNMP request is received, the module checks the flag. The module starts a new collection only if no SNMP requests are outstanding. The module returns an SNMP error if requests are outstanding.