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

Frank Fock fock at agentpp.com
Sat Jan 23 10:32:03 CET 2010



On 23.01.2010 01:03, pradip de wrote:
> Thanks for the reply. So, what I observe when I look at the trap
> internals in wireshark is that the enterprise OID is 1 ID less than what
> I send in the notification OID which is more than what the actual
> enterprise ID should be.

I do not understand what you want to point out with the above?

> Also, should the instance OID for a trap packet instance be prefixed by
> the notification OID? Could the instance suffix be anything, eg a

No!

> timestamp converted into a string of IDs?

No! It must be the instance ID of the particular instance
you refer to. See the SNMP RFCs for details.

> Could you please point out the places in the code below that are incorrect.
> thanks,
> Pradip
>
> On Fri, Jan 8, 2010 at 1:52 PM, Frank Fock <fock at agentpp.com
> <mailto:fock at agentpp.com>> wrote:
>
>
>     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 <mailto: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
>
>     _______________________________________________
>     SNMP4J mailing list
>     SNMP4J at agentpp.org <mailto: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