Fire an event every time there is a set

Hi frank, I have an agent generated by agenpro. Is there a way to fire an event when a set to the mib is detected?
Thanks.

Sure, you can use the the MOLookupListener interface and add your implementation to DefaultMOServer by DefaultMOServer (SNMP4J-Agent 3.6.0)
With the MOServerLookupEvent.getIntendedUse (MOServerLookupEvent (SNMP4J-Agent 3.6.0)) method you can find out if a write operation (i.e., SET request) has triggered the lookup.

Hi frank, I’m kinda of a newbie with this matter, is there any example on how to do that?
Thanks.

Sure see: https://www.agentpp.com/download/SNMP4J-Agent-Instrumentation-Guide-2.2.pdf

Hi Frank, after reading the documentation I still don’t quite get it, can you show me a quick exemple where I send a snmpset to a table and the event fired is just a simple print of the value and the OID? I already get the fact that you need to use MOServerLookupEvent.getIntendedUse in the lookupEvent method of the listener, but how can I get the OID of the table looked up ?
Thanks in advance for the help and atention.

You can print the variable binding from the Request:

public void lookupEvent(MOServerLookupEvent event) {
    if (event.getQuery() instanceof MOQueryWithSource) {
        System.out.println(((Request)((MOQueryWithSource)event.getQuery()).getSource()).find(event.getQuery().getLowerBound()).getVariableBinding());
    }
}

Okay, that makes sense, I’m going to try it. Just one more question, I still don’t know what I need to pass in the second argument of the addLookupListener , the ManagedObject<?>, can you help?

That ManagedObject is the MOScalar or DefaultMOTable for which you are interested. Thus you will be called back if this ManagedObject is being looked up for processing a SNMP request.
But for GETNEXT and GETBULK, this not necessarily means that this ManagedObject will actually process the request, for example if the table is empty.