[SNMP4J] How to use ProxyForwarder
Kanda Norimichi
nkanda at fsi.co.jp
Mon Mar 26 04:53:48 CEST 2007
Dear Mr. Fock:
Thank you for your reply.
I can do work without fear.
I appreciate your kind cooperation.
Sincerely.
Norimichi Kanda.
> -----Original Message-----
> From: Frank Fock [mailto:fock at agentpp.com]
> Sent: Saturday, March 24, 2007 6:52 PM
> To: Kanda Norimichi
> Cc: snmp4j at agentpp.org
> Subject: Re: [SNMP4J] How to use ProxyForwarder
>
>
> Dear Mr. Norimichi,
>
> To implement a proxy forwarder it is not
> necessary to add a command or notification
> listener yourself. Extending the BaseAgent
> class and adding your own configuration for
> the proxy forwarder and target MIB is
> enough.
>
> Best regards,
> Frank
>
> Kanda Norimichi wrote:
> > Dear Mr. Fock:
> >
> > Thank you very much for your reply of March 21.
> >
> > I tried to fix ProxyForwarderImpl.java following your advice and check the operation.
> > So I could confirm it was set intended contextEngineID and contextName.
> >
> > But I found another problem.
> > For a Trap from MA, two same forwarding Traps were sent to NMS.
> >
> > It was caused by adding listener to MessageDispatcher doubly.
> > ----
> > Thread [DefaultUDPTransportMapping_0.0.0.0/162] (Suspended (entry into method processPdu in CommandProcessor))
> > CommandProcessor.processPdu(CommandResponderEvent) line: 84
> > Snmp$NotificationDispatcher.processPdu(CommandResponderEvent) line: 1617
> > Snmp.fireProcessPdu(CommandResponderEvent) line: 1281
> > Snmp.processPdu(CommandResponderEvent) line: 1144
> > MessageDispatcherImpl.fireProcessPdu(CommandResponderEvent) line: 573
> > MessageDispatcherImpl.dispatchMessage(TransportMapping, MessageProcessingModel, Address, BERInputStream) line: 260
> > MessageDispatcherImpl.processMessage(TransportMapping, Address, BERInputStream) line: 320
> > MessageDispatcherImpl.processMessage(TransportMapping, Address, ByteBuffer) line: 282
> > DefaultUdpTransportMapping(AbstractTransportMapping).fireProcessMessage(Address, ByteBuffer) line: 83
> > DefaultUdpTransportMapping$ListenThread.run() line: 323
> >
> > Thread [DefaultUDPTransportMapping_0.0.0.0/162] (Suspended (entry into method processPdu in CommandProcessor))
> > CommandProcessor.processPdu(CommandResponderEvent) line: 84
> > MessageDispatcherImpl.fireProcessPdu(CommandResponderEvent) line: 573
> > MessageDispatcherImpl.dispatchMessage(TransportMapping, MessageProcessingModel, Address, BERInputStream) line: 260
> > MessageDispatcherImpl.processMessage(TransportMapping, Address, BERInputStream) line: 320
> > MessageDispatcherImpl.processMessage(TransportMapping, Address, ByteBuffer) line: 282
> > DefaultUdpTransportMapping(AbstractTransportMapping).fireProcessMessage(Address, ByteBuffer) line: 83
> > DefaultUdpTransportMapping$ListenThread.run() line: 323
> > ----
> >
> > Tentatively I resolved the problem by changing second argument of
> > session.addNotificationListener()
> > at the 114th line in TestProxy.java to dummy listener.
> > ----
> > // // NOTE: 2nd trial and error
> > // session.addNotificationListener(new UdpAddress(162), agent);
> >
> > // NOTE: 3rd trial and error
> > session.addNotificationListener(new UdpAddress(162), new CommandResponder() {
> > public void processPdu(CommandResponderEvent event) {
> > // NOTE: dummy listener
> > }
> > });
> > ----
> > Is it the right resolution?
> >
> > Also, when I make my program generating Snmp instance as well as 'session'
> > for receiving the Trap at the instance,
> > is it no problem with taking same way : setting CommandProcessor instance as
> > the listener which is added Snmp instance?
> >
> > Sincerely.
> >
> > Norimichi Kanda
> >
> >> -----Original Message-----
> >> From: Frank Fock [mailto:fock at agentpp.com]
> >> Sent: Wednesday, March 21, 2007 4:25 AM
> >> To: Kanda Norimichi
> >> Cc: snmp4j at agentpp.org
> >> Subject: Re: [SNMP4J] How to use ProxyForwarder
> >>
> >>
> >> Hi Kanda,
> >>
> >> This is indeed a bug which can be fixed
> >> by the following patch on ProxyForwarderImpl.java:
> >>
> >> @@ -199,6 +199,7 @@
> >> }
> >> PDU reqPDU = request.getCommandEvent().getPDU();
> >> PDU pdu = DefaultPDUFactory.createPDU(target, reqPDU.getType());
> >> + setScope(request, pdu);
> >> try {
> >> proxyForwardTranslation(request, reqPDU, pdu);
> >> ResponseEvent response = null;
> >> @@ -402,6 +403,7 @@
> >> try {
> >> PDU reqPDU = request.getCommandEvent().getPDU();
> >> PDU pdu = DefaultPDUFactory.createPDU(target,
> >> reqPDU.getType());
> >> + setScope(request, pdu);
> >> proxyForwardTranslation(request, reqPDU, pdu);
> >> ResponseEvent resp = session.send(pdu, target);
> >> if (logger.isInfoEnabled()) {
> >> @@ -436,6 +438,14 @@
> >> return allOK;
> >> }
> >>
> >> + private void setScope(ProxyForwardRequest request, PDU pdu) {
> >> + if (pdu instanceof ScopedPDU) {
> >> + ScopedPDU scopedPDU = (ScopedPDU)pdu;
> >> + scopedPDU.setContextEngineID(request.getContextEngineID());
> >> + scopedPDU.setContextName(request.getContext());
> >> + }
> >> + }
> >> +
> >>
> >> Please let me know if this fixes the issue!
> >>
> >> Best regards,
> >> Frank
> >>
> >>
> >> Kanda Norimichi wrote:
> >>> Dear Mr. Fock:
> >>>
> >>> I am Kanda and I work at Fujisoft.
> >>>
> >>> I hope to use ProxyForwarder.
> >>> But SNMPv1-Trap forward doesn't operate correctly.
> >>>
> >>> I'll show below specifically.
> >>> I'm designing the following system structure.
> >>>
> >>> MA - TestProxy - NMS
> >>>
> >>> "MA" is Managed-Agent, it is SNMP agent that support SNMPv1.
> >>> I hope that message from MA will be forwarded to NMS with
> >>> the addition of contextEngineID that generated from
> >>> MA's IP address in TestProxy and fixed contextName.
> >>>
> >>> But in TestProxy made by our system, contextEngineID configured actually is
> >>> replaced by snmpEngineID of TestProxy.
> >>> ContextEngineID and contextName that should be configured forwarded Trap are
> >>> already added to snmpCommunityTable.
> >>>
> >>> I guess, maybe I failed in making TestProxy.
> >>> But I couldn't find sample program and I have no idea what should I do.
> >>> Would you give me any advice?
> >>>
> >>> I'll attach TestProxy made by arranging org.snmp4j.agent.test.TestAgent.
> >>>
> >>> Sincerely.
> >>>
> >>> Norimichi Kanda
> >>> ----
> > [deleted]
> >>> ----
> >>>
> >>> _______________________________________________
> >>> 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
> >>
> > _______________________________________________
> > 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
>
More information about the SNMP4J
mailing list