Checking requests received through SNMP

So, I'm still involved in SNMP training, please say goodbye. I use snmp4j, not just libraries, but I downloaded the source code, and I am not against changing the source if it gets me what I need. I programmed an agent and a test client. What I want to do is check the requests coming from the test client, and, in particular, listen to the β€œgiven” request to a specific OID.

The current method I'm going to do is to catch the request right after running the snmp4j fireProcessMessage method (located in the package org.snmp4j.transport.DefaultUdpTranportMapping ), but I do not know how the agent requests its own mib for. Is there a method that the agent uses to get OID values ​​from its mib?

Or is there a better way to catch a specific SET request? Is it possible to do what I want? Basically, what I want to do is start another process if the client sets a specific OID value of 1 (true).

+4
source share
2 answers

This can be done by extending CommandProcessor and implementing RequestHandler

as i did

 public class SNMPRequestProcessor extends CommandProcessor { SetHandler setHandler = new SetHandler (); public SNMPRequestProcessor() { //Your code } @Override protected void processRequest(CommandResponderEvent command, CoexistenceInfo cinfo, RequestHandler handler) { synchronized (command) { if (command.getPDU().getType() == PDU.SET) { super.processRequest(command, cinfo, setHandler); } super.processRequest(command, cinfo, handler); } } /** * Handler for process set request which update to the database * */ class SetHandler implements RequestHandler { @Override public boolean isSupported(int mode) { return mode == PDU.SET; } @Override public void processPdu(Request request, MOServer server) { //your code } } } 
+11
source

I have no experience working with snmp4j agent, but I recommend asking this question on the official mailing list: http://lists.agentpp.org/pipermail/snmp4j/ . He is quite active, you will have a good answer in a few hours.

0
source

All Articles