How to capture and handle 'snmp-net' commands like snmpget, snmpset

Hi ,

I want to capture and handle snmp-net commands in backend to apply config file before we send response to client side.
For eg, if we execute snmpget before we send response to client can we apply config file in backend (java)?

You are referring to processing different SNMP PDU types (GET, SET, etc.) in a command responder (i.e. agent) application.

That is covered by SNMP4J-Agent, but not based on “config files”. Instead ManagedObject instances handle the sub-requests of an incoming SNMP PDU.

You can implement your own (set of) managed objects to interpret config files before responding - that is no problem. Maybe there is a general misunderstanding how SNMP works on the agent side? But I could be wrong too - I do not know what you expected as an answer?

Hi ,
I am abe to interpret snmp net commands like snmpset , snmpget by extending MessageDispatcherImpl class.But now the problem is, if snmpget request didn’t pass my filter part i need to pass an error message (customized) to terminal or where client is running.
I tried some scenarios but it always shows Timeout: No Response from {serverip}

Could you please suggest me on this??is it possible to form customised message and send that to terminal ??

No, with SNMP you can return the standard error status values only. There is no way to directly return error messages. But you can of course, implement a real SNMP agent with your own MIB specification an provide a table or scalar MIB object that contains the error condition as text (you need then to establish a link between that object and your request with a third object (e.g. TestAndIncr).

Another option would be sending a NOTIFICATION or INFORM PDU to the command generator.

I would still recommend using SNMP4J-Agent for any kind of command-responder. Doing the job with SNMP4J alone will most likely lead to some non-standard, in-secure, and non-interoperable implementation.