[SNMP4J] The OID parameter of NotificationOriginator.notify(..)

Frank Fock fock at agentpp.com
Fri Jan 8 22:52:46 CET 2010


Hi Pradip,

The notification OID is the OID of the NOTIFICATION-TYPE.
A notification type has never an instance. Thus, no
instance suffix is appended to its OID.
For TRAP-TYPEs the coexistence RFCs provide a mapping
to a notification OID.

The timstamp VB must be included in the payload,
the NotificationOriginator does that for you.

The sample code below is incorrect, in several
aspects.

Regards,
Frank

On 07.01.2010 02:50, pradip de wrote:
> Hi,
> I am using NotificationOriginator.notify(...) to send traps to different
> targets over both SNMPv1 and SNMPv2c. I had a few questions regarding the
> OID passed to this method and how the fields in the Trap packet get
> populated from it.
> 1. Should this OID be the OID of this particular instance of the trap
> packet? ie., including the instance ID after the specific ID of the trap?
> 2. How do the enterprise ID and the specific ID of the traps get picked from
> the OID I pass for each of the snmp versions? I am actually using a
> timestamp of the event as the instance ID to append after the specifc ID of
> the trap type to form the OID of the variable binding. However, I am
> noticing in wireshark that the trap to the second target(I have 2 targets,
> first for version 1 and second for version v2c) is also picking up the
> instanceID from the first one.
> 3. Is it better to use the notificationOriginator.notify(..) method to send
> traps to a set of preconfigured targets or do I lose some control on how the
> trap packet is formed? Should I instead formulate the packets from scratch
> using the snmp4j APIs for a trap PDU?
> Below is my sendTrap method that calls the notificationOriginator.notify()
> function using a oid upto the specific ID for this trap type.
> thanks,
> Pradip
>
> public void sendTrap(OID oid, String payload) throws Exception {
>
>          /* Create variable bindings for Trap packet */
>          VariableBinding[] vbs = new VariableBinding[1];
>
>          OID instanceOid = oid;
>          instanceOid.append(Long.toString(event.getCreationTimeLong()));
>
>          VariableBinding vb = new VariableBinding();
>          vb.setOid(instanceOid);
>          OctetString oStr = new OctetString(payload);
>          vb.setVariable((Variable) oStr);
>          vbs[0] = vb;
>
>          notificationOriginator.notify(new OctetString(), oid, vbs);
>      }
> _______________________________________________
> SNMP4J mailing list
> SNMP4J at agentpp.org
> http://lists.agentpp.org/mailman/listinfo/snmp4j

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




More information about the SNMP4J mailing list