Example of configuring trap recipients?

Frank Fock Frank.Fock____t-online.de
Fri Jan 28 12:34:23 CET 2000


Hi Jeff,

for the AGENT++3.4 release I have implemented an easy to use
method to add an v1 trap destination. It adds an entry (row) to
each of the following tables:

1. snmpTargetParamsTable
2. snmpTargetAddrTable
3. snmpNotifyTable

The ::add_entry methods referenced in the examples code
attached are not implemented in release 3.3. If you would
like to get the code - just email me.

Best regards,
Frank

Jeff Stewart wrote:

>     I'm trying to get a small custom agent running using Agent++.  I've
> got the library built and working for a small proxying server.  Now I'm
> trying to originate some traps, starting with a coldStart trap.  The
> code to originate the trap seems straightforward.
>     Unfortunately, what I can't figure out is how I configure the trap
> recipients.  It looks like I need to add a row to the
> snmpNotifyEntry::instance and one to the snmpTargetAddrEntry::instance.
>     Does anyone have an example of setting up these tables, either from
> persistent storage, or programmatically?  Even just knowing what the
> fields are supposed to be would help.  Here's what I've guessed so far:
>
>     snmpNotifyEntry: text Label?, trap(1)/notify(2), persistence?,
> async(4)/block(5)
>     snmpTargetAddrEntry: ?
>
>     Jeff
-------------- next part --------------
boolean NotificationOriginator::add_v1_trap_destination(const UdpAddress& addr)
{
	OctetStr name("defaultV1Trap");
	OctetStr tag("v1trap");
	if (snmpTargetParamsEntry::instance->add_entry(name, // row index
						       1,    // mpModel 
						       1,    // securityModel
						       "public", // secName
						       1)) { // secLevel
	  OctetStr address;
	  for (int i=0; i<4; i++) {
		address += addr[i];
	  }
	  address += addr.get_port() >> 1;
	  address += addr.get_port() & 0x0F;
	  if (snmpTargetAddrEntry::instance->
	      add_entry(name,                     // row index
			Oidx("1.3.6.1.6.1.1"),    // UDP domain
			address,                  // target address
			tag,                      // tag
			name)) {                  // params entry
	    if (snmpNotifyEntry::instance->add_entry(name, // row index 
						     tag,  // tag
						     1))   // type (trap)
		return TRUE;
	  }
	}
	return FALSE;
}



More information about the AGENTPP mailing list