Solaris System Management Agent Developer's Guide

Storing Persistent Data

Your module must use the read_config_store_data() and read_config_store() functions together with callback functions to store data.

Your module must first register a callback with the snmp_register_callback() function so that data is written to the configuration file when the agent shuts down.

The snmp_register_callback() function is as follows:

int snmp_register_callback(int major, 
                           int minor, 
                           SNMPCallback *new_callback, 
                           void *arg);

You must set major to SNMP_CALLBACK_LIBRARY, set minor to SNMP_CALLBACK_STORE_DATA. When arg is not set to NULL, arg is a void pointer used whenever the new_callback function is exercised.

The prototype to your callback function, the new_callback pointer, is as follows:

int (SNMPCallback) (int majorID, 
                    int minorID, 
                    void *serverarg, 
                    void *clientarg);

See the API documentation for more information about setting up callback registrations with the agent at /usr/sfw/doc/sma_snmp/html/group__callback.html.

The read_config_store_data() function should be used to create the token-value pair that is to be written into the module's configuration file. The read_config_store() function actually does the storing when the registered callbacks are exercised upon agent shutdown.


Note –

When your module stores persistent data, you might find that the configuration file is written to the /var/sma_snmp directory. Modified token-value pairs are appended to the file, rather than overwriting the previous token-value pairs in the file. The last values that were defined in the file are the values that are used.