Data is read from the configuration files into a module by registering a callback function to be called whenever an appropriate token is encountered. For example, you can call the function as follows:
register_config_handler(demo_module_4, threshold_loadavg1, read_load_thresholds, NULL, NULL);
Whenever a threshold_loadavg1 token in the demo_module_4 file is read by the agent, the function read_load_thresholds() is called with token name and value as arguments. The read_load_thresholds() function stores the token value in appropriate variables:
void read_load_thresholds(const char *token, char *cptr) { if (strcmp(token, "threshold_loadavg1") == 0) { threshold_loadavg1=atof(cptr); } else if (strcmp(token,"threshold_loadavg5") == 0) { threshold_loadavg5=atof(cptr); } else if (strcmp(token,"threshold_loadavg15") == 0) { threshold_loadavg15=atof(cptr); } else { /* Do nothing */ } return; }
See the API documentation about register_config_handler() in /usr/sfw/doc/sma_snmp/html/group__read__config.html for more information.