JavaScript is required to for searching.
Skip Navigation Links
Exit Print View
Solaris System Management Agent Developer's Guide
search filter icon
search icon

Document Information


1.  Introduction to the System Management Agent

2.  Creating Modules

3.  Data Modeling

4.  Storing Module Data

About Storing Module Data

Configuration Files

Defining New Configuration Tokens

Implementing Persistent Data in a Module

Storing Persistent Data

Reading Persistent Data

demo_module_5 Code Example for Persistent Data

Storing Persistent Data in demo_module_5

Reading Persistent Data in demo_module_5


5.  Implementing Alarms

6.  Deploying Modules

7.  Multiple Instance Modules

8.  Long-Running Data Collection

9.  Entity MIB

10.  Migration of Solstice Enterprise Agents to the System Management Agent

A.  SMA Resources

B.  MIBs Implemented in SMA



Implementing Persistent Data in a Module

The module can register handlers that are associated with tokens in a module-specific configuration file with the register_config_handler() function. The handlers can then be used later in the module for a specific task.

The register_config_handler() is defined as follows:

register_config_handler (const char *type_param, const char *token, 
                    void(*parser)(const char *, char *),
                    void(*releaser)(void), const char *help)   

The first argument to this function designates the base name of the configuration file, which should be the same as the name of the module. For example, if the first argument is my_custom_module, then the agent infrastructure looks for the configuration tokens in the file my_custom_module.conf. Note that you must create the configuration file manually before the module can use the file.

The second argument to this function designates the configuration token that the module is looking for.

For more information about register_config_handler() and other related functions, see the API documentation in /usr/sfw/doc/sma_snmp/html/group__read__config.html. You can also look at /usr/demo/sma_snmp/demo_module_5/demo_module_5.c to see how the function is used.

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.

Reading Persistent Data

Data is read from a module's configuration file into the module by using the register_config_handler() function. For example, you can call the function as follows:

register_config_handler("my_module", "some_token",
                            load_my_tokens, NULL, NULL);

Whenever the token some_token is read by the agent in my_module.conf file, the load_my_tokens() function is called with token name and value as arguments. The load_my_tokens() function is invoked. The data can be parsed by using the read_config_read_data() function.