notification.c如下所示,每个30秒发送一个trap给mib browser。
#include#include#include
/** contains prototypes*/#include"notification.h"
/** our initialization routine
* (to get called, the function name must match init_FILENAME()*/
voidinit_notification(void)
{
DEBUGMSGTL(("example_notification","initializing (setting callback alarm)\n"));
snmp_alarm_register(30, /*seconds*/SA_REPEAT,/*repeat (every 30 seconds).*/send_example_notification,/*our callback*/NULL/*no callback data needed*/);
}voidsend_example_notification(unsignedint clientreg, void *clientarg)
{/** define the OID for the notification we're going to send
* NET-SNMP-EXAMPLES-MIB::netSnmpExampleHeartbeatNotification*/oid notification_oid[]={1, 3, 6, 1, 4, 1, 8072, 2, 3, 0, 1};
size_t notification_oid_len=OID_LENGTH(notification_oid);static u_long co