Solaris System Management Agent Developer's Guide

Using SNMP_CALLBACK_POST_READ_CONFIG in demo_module_4

A few seconds elapse after agent startup while all configuration tokens are read by the module. During this interval, the module should not perform certain functions. For example, until the threshold settings are read from configuration files into the module, trap condition checks should not be performed. To handle these cases, a callback function can be set. This callback function is called when the process of reading the configuration files is complete. For example, you can call the function as follows:


snmp_register_callback(SNMP_CALLBACK_LIBRARY, 
SNMP_CALLBACK_POST_READ_CONFIG,demo_4_post_read_config, NULL);

The demo_4_post_read_config() function is called after the configuration files are read. In this example, the demo_4_post_read_config() function registers refresh callbacks:

int demo_4_post_read_config(int a, int b, void *c, void *d)
{

    /* Refresh the load data every 60 seconds */
    snmp_alarm_register(60, SA_REPEAT, refreshLoadAvg, NULL);

    /* Acquire the data first time */
    refreshLoadAvg(0,NULL);

}