Solaris System Management Agent Developer's Guide

Using SNMP_CALLBACK_POST_READ_CONFIG in demo_module_5

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 persistent file names are read from /var/sma_snmp/demo_module_5.conf into the module, the file table cannot be populated. 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 might call the function as follows:


snmp_register_callback(SNMP_CALLBACK_LIBRARY,
 SNMP_CALLBACK_POST_READ_CONFIG, demo_5_post_read_config, NULL);

The demo_5_post_read_config() function is called after the configuration files are read. In this example, the demo_5_post_read_config() function populates the file table, then registers the callback function for data persistence.

int
demo5_post_read_config(int a, int b, void *c, void *d)
{   if (!AddItem(file1))
     snmp_log(LOG_ERR, "Failed to add instance in init_demo_module_5\n");
  if (!AddItem(file2))
     snmp_log(LOG_ERR, "Failed to add instance in init_demo_module_5\n");
  if (!AddItem(file3))
     snmp_log(LOG_ERR, "Failed to add instance in init_demo_module_5\n");
  if (!AddItem(file4))
     snmp_log(LOG_ERR, "Failed to add instance in init_demo_module_5\n");


snmp_register_callback
(SNMP_CALLBACK_LIBRARY, SNMP_CALLBACK_STORE_DATA,
demo5_persist_data, NULL);

}