[AGENT++] Agent++ crash when trying to send a trap

Frank Fock fock at agentpp.com
Tue Feb 20 20:55:32 CET 2007


Hello Razvan,

You need to initialize and setup the SNMP-NOTIFICATION-MIB
and the SNMP-TARGET-MIB in order to tell the agent
when and where to send the trap/notification.

Best regards,
Frank


Razvan Cojocaru wrote:
> Hello.
> 
> My code is:
> 
> int main()
> {
>     int status;
>     Snmp::socket_startup();  // Initialize socket subsystem
>     Snmpx snmp(status, 161);
> 
>     if(status != SNMP_CLASS_SUCCESS) {
>         cerr << snmp.error_msg(status) << endl;
>         return 1;
>     }
> 
>     RequestList rql;
> 
>     Mib mib;
> 
>     mib.add(new TestResponder);
>     mib.add(new TestTable);
> 
>     mib.init();
> 
>     rql.set_snmp(&snmp);
>     mib.set_request_list(&rql);
> 
>     Request* req = NULL;
> 
>     Vbx* vbs = 0;
>     coldStartOid coldOid;
>     NotificationOriginator no;
>     UdpAddress dest("127.0.0.1/162");
>     no.add_v1_trap_destination(dest);
>     no.generate(vbs, 0, coldOid, "", "");
> 
>     for(;;) {
>         req = rql.receive(120); // 120 seconds timeout
> 
>         if(req)
>             mib.process_request(req);
>     }
> 
>     Snmp::socket_cleanup();  // Shut down socket subsystem
> 
>     return 0;
> }
> 
> This crashes the application in no.generate(vbs, 0, coldOid, "", "");.
> GDB backtrace below:
> 
> Program received signal SIGSEGV, Segmentation fault.
> [Switching to Thread 16384 (LWP 22886)]
> 0x400c89c8 in Agentpp::NotificationOriginator::generate
> (this=0xbffff380, vbs=0x0, size=0, id=@0xbffff1d0, timestamp=1234890437,
> enterprise=@0xbffff1f0,
>     contextName=@0xbffff210) at notification_originator.cpp:163
> 163             List<MibTableRow>* typeList =
> (gdb) l
> 158     {
> 159             // We have to be careful here about synchronisation because,
> 160             // we may be called after an interrupt
> 161             // Therefore synch everything or use synch methods like
> 162             // MibTable::get_rows_cloned();
> 163             List<MibTableRow>* typeList =
> 164               snmpNotifyEntry::instance->get_rows_cloned();
> 165             ListCursor<MibTableRow> typeCur;
> 166
> 167             List<MibTableRow>* list =
> (gdb) p snmpNotifyEntry::instance
> $1 = (Agentpp::snmpNotifyEntry *) 0x0
> 
> I'm using Agent++ with the _NO_SNMPv3 enabled, and multi-threading
> support, and compile this code with:
> 
> $(CXX) -pthread -g -O0 -W -Wall -o test1 test1.cpp -lagent++ -lsnmp++ -ldes
> 
> My system is Slackware Linux 10.2, kernel v2.4.
> 
> Am I missing some initialization step for the traps subsystem?
> Thanks.
> 
> 

-- 
AGENT++
http://www.agentpp.com
http://www.mibexplorer.com
http://www.mibdesigner.com




More information about the AGENTPP mailing list