[AGENT++] newbie: How to send trap via agent++?

Jochen Katz katz at agentpp.com
Mon Feb 26 23:51:40 CET 2007


Hi,

> I just want to send a trap.
> 
> I found the following in the FAQ.
>        Vbx* vbs = 0;
>     coldStartOid coldOid;
>     Mib::notify(vbs, 0, coldOid, "", "");
> 
> I tried this but get the following error.
> agent.cpp:432: error: no matching function for call to
> `Agentpp::Mib::notify(Agentpp::Vbx*&, int, coldStartOid&, const
> char[1], const char[1])'

obviously this FAQ entry is a bit outdated, but you found the right code
in the examples...

> And In the examples/static_table/src/agent.cpp file I found the following:
> no.generate(vbs, 0, coldOid, "", "");
> 
> localhost [127.0.0.1]: Trap DISMAN-EVENT-MIB::sysUpTimeInstance =
> Timeticks: (230) 0:00:02.30, SNMPv2-MIB::snmpTrapOID.0 = OID:
> SNMPv2-MIB::coldStart
> 
> But I still haven't sent a trap, right?

No, it is a version 1 trap. Above the generate() call, a call to
add_v1_trap_destination() configures the tables for v1. If you change
this to add_v2_trap_destination() you will get a v2 trap. Note that in
current agent++ version it is not allowed to call the add_vX_trap...
functions more than once.

> I'm tempted to just use the snmp++ sample code but I have been
> *advised* that the agent++ package will provide me with advantages
> over the snmp++ code.  Are there advantages?

If your application just has to send a trap (as you wrote above) and
doesn't have to respond to any manager requests, you should use snmp++.
If you need a real agent, you should use agent++.

Regards,
  Jochen




More information about the AGENTPP mailing list