[SNMP4J] Snmp4j agent -- can print and store the incoming requests

nitin sharma kumarsharma.nitin at gmail.com
Mon Jan 19 05:20:04 CET 2015


thanks Shivi...

-- Kindly excuse me for this lengthy email.....


i looked at the CommandResponder interface, it does have "ProcessPdu". i
created a class ( Snmp_commandResponder) that implements this interface and
overrides ProcessPdu(CommandResponder event) method. right now i am just
printing event.toString() and getting the following text..

==========================
*processPdu received!CommandResponderEvent[securityModel=2,
securityLevel=1, maxSizeResponsePDU=65535, pduHandle=PduHandle[16071],
stateReference=StateReference[msgID=0,pduHandle=PduHandle[16071],securityEngineID=null,securityModel=null,securityName=public,securityLevel=1,contextEngineID=null,contextName=null,retryMsgIDs=null],
pdu=GETBULK[requestID=16071, errorStatus=Success(0), errorIndex=16, VBS[0.0
= Null]], messageProcessingModel=1, securityName=public, processed=false,
peerAddress=127.0.0.1/65469 <http://127.0.0.1/65469>,
transportMapping=org.snmp4j.transport.DefaultUdpTransportMapping at 16f144c,
tmStateReference=null]*

*=====================*

However, CommandResponder doesn't have method for sending back the snmp
message. So, i looked at the CommandProcessor class in org.snmp4j.agent
package.. this class too have ProcessPdu method. Well, as a quick and dirty
way i changed my Snmp_commandResponder to extend from CommandProcessor and
in overwritten ProcessPdu method, i am calling super.ProcessPdu(event).

My code is working, but i would like to know
a. if that is a correct way?
b. is the printed Pdu message (above) seems to be a correct one?
c. Is there a way i can get to know source server and port from where the
request to my client was originated ?

my Code is attached as zip file to this email



Regards,
Nitin Kumar Sharma.


On Thu, Jan 15, 2015 at 10:46 PM, Shivi Goel -X (shivigoe - NICHEPRO
TECHNOLOGIES PRIVATE LIMITED at Cisco) <shivigoe at cisco.com> wrote:

> Hi Nitin,
> An incoming request or notification is stored as an instance of
> CommandRespondentEvent class in snmp4j. This class gives you api to get pdu
> and other info.
> Please refer to the API doc:
> http://www.snmp4j.org/doc/org/snmp4j/CommandResponderEvent.html
>
> Regards,
> Shivi
>
> -----Original Message-----
> From: SNMP4J [mailto:snmp4j-bounces at agentpp.org] On Behalf Of nitin sharma
> Sent: Friday, January 16, 2015 7:35 AM
> To: snmp4j at agentpp.org
> Subject: [SNMP4J] Snmp4j agent -- can print and store the incoming requests
>
> HI team,
>
> I am building a Snmp4j agent code that will print the incoming Snmp
> request . is it possible scenario to be coded? if yes, then please do
> provide some guidance.
>
> Regards,
> Nitin Kumar Sharma.
> _______________________________________________
> SNMP4J mailing list
> SNMP4J at agentpp.org
> https://oosnmp.net/mailman/listinfo/snmp4j
>



More information about the SNMP4J mailing list