Unregister OIDs


I have a list of OIDs that I create dynamically depending on a list of running tasks.
My snmp Agent has to manage this dynamic tasks. Each task has a dynamic OID built as follow : <PREFIX_TASK_OID>.<TASK_NUM>.0

When a task is created, my agent associates a dynamic OID to the task, then it registers it in the MIB.
Therefore a manager can call GET/SET requests to get some information or to stop the task.
When the task is stopped or finished, the associated OID should be unregistered.
The question is : How can I unregister this OID from the MIB. I do not found any instruction in snmp4j to do that ?
An example would be appreciated.
Thanks for your support.

Hi Michel,

First of all, such kind of dynamic MIB objects should be implemented using SNMP tabular objects. Each dynamic “object” would then be represented by a row in that table.

To “register” or “unregister” such a row, use the DefaultMOTable.addRow and .removeRow methods.

If you really need to register/unregister a whole ManagedObject at runtime, you can simply call DefaultMOServer.register and .unregister methods.

BTW, SNMP4J itself is not well suited to implement a SNMP agent (command responder). You can do so, but most developers will fail with that. Instead use SNMP4J-Agent on top of SNMP4J and you will save years of development effort.

Best regards,

Hi Franck,
Thanks for the response. I tested the method unregister. It works !
My snmp agent is based on SNMP4J-Agent API.
I have another question regarding the MIB. How can I expose the MIB to the external application.
For the moment when I send snmp walk command I get all registered OIDs (tested with snmpnet tool)
Some SNMP applications can load MIB from the server.
How can I do that with our MIB ?
Best regards