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

pradip de pradip.de at gmail.com
Thu Jan 7 02:50:24 CET 2010


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);
    }



More information about the SNMP4J mailing list