[SNMP4J] possible bug in org.snmp4j.agent.mo.snmp.NotificationOriginatorImpl
Yuan Ding
yding at goldengate.com
Fri Apr 27 23:59:45 CEST 2007
Hi Frank,
Yes, I totally missed that part. I will take a look at that direction.
Thanks for the help.
best regards,
yuan
-----Original Message-----
From: Frank Fock [mailto:fock at agentpp.com]
Sent: Friday, April 27, 2007 2:48 PM
To: Yuan Ding
Cc: snmp4j at agentpp.org
Subject: Re: [SNMP4J] possible bug in
org.snmp4j.agent.mo.snmp.NotificationOriginatorImpl
Hi Yuan,
To filter notification entries based on the notification
ID, you need to add (setup) the appropriate
snmpNotifyFilterEntry rows.
Best regards,
Frank
Yuan Ding wrote:
> Hi Frank,
>
> I have two notification entries. One with only one variable binding,
the
> other notification have 6. Both notifications are sent to the same
> target address.
>
>
> The expected result is: when I send the notification - ID:
> 1.3.6.1.4.1.18657.10.0.1 (type 1 , with 1 variable binding), only one
> trap should be sent out, and when I send the notification - ID
> 1.3.6.1.4.1.18657.10.0.2 (type 2, with 6 variable bindings), only one
> notification should be sent out.
>
> Currently two identical type 1 notifications and two identical type 2
> notifications are sent to the target address.
>
> thanks and regards,
> yuan
>
>
>
> -----Original Message-----
> From: Frank Fock [mailto:fock at agentpp.com]
> Sent: Friday, April 27, 2007 2:26 PM
> To: Yuan Ding
> Cc: snmp4j at agentpp.org
> Subject: Re: [SNMP4J] possible bug in
> org.snmp4j.agent.mo.snmp.NotificationOriginatorImpl
>
> Hi Yuan,
>
> Ok, but that is how it is supposed to work.
> What number of traps do you expect and why?
>
> Best regards,
> Frank
>
> Yuan Ding wrote:
>> Hi Frank,
>>
>> Here is the code snippet:
>>
>> mib = new NodeAgentMibModule(ggAgent);
>> mib.loadNotificationEntry();
>> ArrayList<String> targetAddrList = mib.getTargetAddressList();
>> for (int i = 0; i < targetAddrList.size(); i++) {
>> targetMIB.addTargetAddress(new OctetString("notification"),
>> TransportDomains.transportDomainUdpIpv4,
>> new OctetString(new
>> UdpAddress(targetAddrList.get(i)).getValue()),
>> 200, 0, //TODO add it to config
>> new OctetString(mib.getTagList()),
>> new OctetString("v2c"),
>> StorageType.permanent);
>> }
>> targetMIB.addTargetParams(new OctetString("v2c"),
>> MessageProcessingModel.MPv2c,
>> SecurityModel.SECURITY_MODEL_SNMPv2c,
>> new OctetString("public"),
>> SecurityLevel.AUTH_PRIV,
>> StorageType.permanent);
>> Set<ObjectName> keyset = mib.getNotificationMap().keySet();
>> Iterator<ObjectName> iter = keyset.iterator();
>> while (iter.hasNext()) {
>> ObjectName objName = iter.next();
>> NotificationEntry entry =
mib.getNotificationMap().get(objName);
>> notificationMIB.addNotifyEntry(new
> OctetString(entry.getOidStr()),
>> new OctetString(entry.getTag()),
>> SnmpNotificationMIB.SnmpNotifyTypeEnum.trap,
>> StorageType.permanent);
>> }
>>
>>
>> Target address are loaded from config file. (1 here)
>> Notifications are loaded from MIB module - 2 here. When one
invocation
>> of
>> getNotificationOriginator().notify(
>> new OctetString("public"), new OID(entry.getOidStr()),
>> vbindings);
>> is called, two notifications are sent out.
>> entry and vbindings are built dynamically, based on notification
type.
>>
>> Thanks for taking a look at this.
>>
>> yuan
>>
>>
>> -----Original Message-----
>> From: Frank Fock [mailto:fock at agentpp.com]
>> Sent: Friday, April 27, 2007 1:47 PM
>> To: Yuan Ding
>> Cc: snmp4j at agentpp.org
>> Subject: Re: [SNMP4J] possible bug in
>> org.snmp4j.agent.mo.snmp.NotificationOriginatorImpl
>>
>> Hi Yuan,
>>
>> From the information you provide, SNMP4J-Agent is
>> working correctly (as expected).
>>
>> Can you provide more details why you think that
>> there is a bug?
>>
>> Best regards,
>> Frank
>>
>> Yuan Ding wrote:
>>> Hi,
>>>
>>>
>>>
>>> I don't know if anyone encounter this before.
>>>
>>>
>>>
>>> It looks like a bug in this class's notify method.
>>>
>>>
>>>
>>> Here is the scenario:
>>>
>>>
>>>
>>> Add two notification entries to notificationMIB in the agent.
>>>
>>> Then send one notification with notificationID (OID) and set all
>>> variable bindings.
>>>
>>>
>>>
>>> The result is: two identical notifications are sent.
>>>
>>>
>>>
>>> I have a temporary fix: while adding notification entry, I use
>>> notificationID as name. Within NotificationOriginatorImpl's notify
>>> method, since there are several private members, I have to clone the
>>> impl class and change "notify" method the following way:
>>>
>>>
>>>
>>> public Object notify(OctetString context, OID notificationID,
>>>
>>> TimeTicks sysUpTime, VariableBinding[] vbs) {
>>>
>>> if (logger.isInfoEnabled()) {
>>>
>>> logger.info("Notification " + notificationID + " issued with "
> +
>>> Arrays.asList(vbs));
>>>
>>> }
>>>
>>> List responses = new LinkedList();
>>>
>>> for (Iterator it =
>>> notificationMIB.getNotifyTable().getModel().iterator();
>>>
>>> it.hasNext(); ) {
>>>
>>> MOTableRow notifyRow = (MOTableRow) it.next();
>>>
>>>
>>>
>>> //==================Start local fix=======================
>>>
>>> // fetch name as OID
>>>
>>> OctetString name = new OctetString();
>>>
>>> name.fromSubIndex(notifyRow.getIndex(), true);
>>>
>>> String notificationIDStr = notificationID.toString();
>>>
>>> if (!notificationIDStr.equals(name.toString())) {
>>>
>>> continue; // skip those notification that does not match
>>> notificationID
>>>
>>> }
>>>
>>> //==================End local fix========================
>>>
>>> ... (the rest of the code)
>>>
>>>
>>>
>>> Let me know if this is truly a bug or the way I am using it is
wrong.
>> If
>>> it's a bug let me know if the fix make sense.
>>>
>>> Thanks
>>>
>>> yuan
>>>
>>>
>>>
>>> This e-mail message and any attachments may contain private,
>> confidential, proprietary or privileged material of GoldenGate
> Software,
>> Inc. that is for the sole use of the intended recipient(s) of this
>> e-mail message. Any review, copying or distribution or other use of
>> this e-mail message or any attachments hereto by anyone other than
the
>> intended recipient(s) is strictly prohibited. If you are not the
>> intended recipient(s) of this e-mail message, please contact
> GoldenGate
>> Software, Inc. (415-777-0200) immediately and permanently delete the
>> original e-mail message and any copies of this e-mail message and all
>> attachments, if any.
>>> _______________________________________________
>>> SNMP4J mailing list
>>> SNMP4J at agentpp.org
>>> http://lists.agentpp.org/mailman/listinfo/snmp4j
>
--
AGENT++
http://www.agentpp.com
http://www.mibexplorer.com
http://www.mibdesigner.com
This e-mail message and any attachments may contain private, confidential, proprietary or privileged material of GoldenGate Software, Inc. that is for the sole use of the intended recipient(s) of this e-mail message. Any review, copying or distribution or other use of this e-mail message or any attachments hereto by anyone other than the intended recipient(s) is strictly prohibited. If you are not the intended recipient(s) of this e-mail message, please contact GoldenGate Software, Inc. (415-777-0200) immediately and permanently delete the original e-mail message and any copies of this e-mail message and all attachments, if any.
More information about the SNMP4J
mailing list