The refreshLoadAvg() function is called at regular intervals to refresh data. Immediately after data is refreshed, the refreshLoadAvg() function checks for trap conditions by calling the following functions:
check_loadavg1_state()
check_loadavg5_state()
check_loadavg15_state()
In me4LoadGroup.c, a module property could be in one of two states: OK or ERROR. When the current data value crosses the threshold, the state is set to ERROR. A trap is then generated. The check functions have the following algorithm:
check_loadavg1_state() {
// Step-1: check condition
if (currentData > threshold_loadavg1) new_loadavg1_state = ERROR;
// Step-2: Generate trap if necessary
if (new_loadavg1_state > prev_loadavg1_state) {
// Send trap
prev_loadavg1_state=new_loadavg1_state;
} else if(new_loadavg1_state == prev_loadavg1_state) {
/* No Change in state .. Do nothing */
} else if (new_loadavg1_state < prev_loadavg1_state) {
if (new_loadavg1_state == OK) {
prev_loadavg1_state=OK;
// Send OK trap
}
}
}
When the check indicates that the threshold has been crossed, the send_v2trap function is used to generate an SNMPv2 trap. The trap OID and the varbinds are as specified in the SDK-DEMO4-MIB.txt MIB. For more information on SNMP trap APIs, see /usr/sfw/doc/sma_snmp/html/group__agent__trap.html.