Question about SNMPv2MIB

Hello Frank
snmpv2MIB includes a leaf:name, our system wants to use it as the global system name, so if the name changes, we want to notify other modules to update, but, the SNMPv2MIB is implemented by snmp4j, we don’t want to rewrite it because it is a build-in class and other build-in class like AgentConfigManager used it for other functionality, do you have any suggestion for requirement?

You can use the MOServer.addLookupListener(..) to get informed when that instance is looked up for update (SET) by a SNMP request:
https://agentpp.com/doc/snmp4j-agent/org/snmp4j/agent/MOServer.html#addLookupListener(org.snmp4j.agent.MOServerLookupListener,org.snmp4j.agent.ManagedObject)
Then you can trigger any actions from the listener: if short running, then synchronously or otherwise in background threads.

Thanks for quick response, I will try it.

Hello Frank
I want to get informed for name in SNMPv2MIB class, but name is private and no method can return it, so it can be used in this method: addLookupListener(), my understanding is that the second parameter I need to fill name in SNMPv2MIB.
Is my understanding is right? Is there another way?Or my understanding is wrong, would you give me an example? Thanks.

I have difficulties to understand what you are trying to achieve: what do you mean by “I want to get informed for name”? The title of the topic is not given that information either (which would others to find the right topic).
Thank you, Frank

Hello Frank
Sorry that the description is not clear. I want to care the changes of mib:sysName, the sysName is implemented in SNMPv2MIB class, the variable is “name” in SNMPv2MIB class,
but variable “name” is private and no method can return it.
for the method you recommend: addLookupListener(), my understanding is that the second parameter I need to fill “name” in SNMPv2MIB. But the “name” is private so I can’t reach my target that care the changes for mib:sysName.
Is my understanding is right? Is there another way? Or my understanding is wrong, would you give me an example? Thanks.

OK, because the MOScalar<OctetSring> name is private in SNMPv2MIB, you cannot directly access it, but you can nevertheless look it up using DefaultMOServer:

ManagedObject<?> sysName = server.getManagedObject(new OID(SnmpConstants.sysName), null);

Then you can add the MOServerLookupListener with:

server.addLookupListener(new MOServerLookupListener() {
...
}, sysName);