[SNMP4J] Registering multiple managed objects and org.snmp4j.agent.DuplicateRegistrationException error

Marek Hajduczenia marek.hajduczenia at gmail.com
Sat Mar 30 14:35:21 CET 2013


Dear colleagues, 

 

I am continuing the development of my project and now I have a rather simple
task that keeps on generating errors for some reason I do not quite
understand. But let me first describe what I am doing and what the output
is:

 

[1] I create 4 individual OID to be used later on 

 

OID oidLocalHostName = new OID(".1.3.6.1.3.22.1.1"); // nomeServidor 

OID oidRootFolder = new OID(".1.3.6.1.3.22.1.2"); // diretoriaBase 

OID oidDefaultPlayer = new OID(".1.3.6.1.3.22.1.3"); // musicPlayer 

OID oidNumberOfMusicFiles = new OID(".1.3.6.1.3.22.1.4"); //
nTotalmMsicasDisp

 

[2] then I try to register individual new managed objects as follows

 

server.registerManagedObject(MOCreator.createReadOnly(oidLocalHostName,
java.net.InetAddress.getLocalHost().getHostName()));

server.registerManagedObject(MOCreator.createReadOnly(oidDefaultPlayer,
"VLC")); // HERE IS THE LINE WITH ERROR

server.registerManagedObject(MOCreator.createReadOnly(oidRootFolder,
folder.getAbsolutePath()));

server.registerManagedObject(MOCreator.createReadOnly(oidNumberOfMusicFiles,
0));

 

the function registerManagedObject is just a simple wrapper defined as
follows:

 

       public void registerManagedObject(ManagedObject mo) 

       {

              try 

              {

                     server.register(mo, null);

              } 

              catch (DuplicateRegistrationException ex) 

              {

                     throw new RuntimeException(ex);

              }

       }

 

I get however the following error on console:

 

208 [main] INFO org.snmp4j.agent.DefaultMOServer  - Registered MO
org.snmp4j.agent.mo.MOScalar[oid=1.3.6.1.3.22.1.1,access=org.snmp4j.agent.mo
.MOAccessImpl at 3ce3e8f3,value=Marek-HP,volatile=false] in default context
with scope
org.snmp4j.agent.mo.MOScalar[oid=1.3.6.1.3.22.1.1,access=org.snmp4j.agent.mo
.MOAccessImpl at 3ce3e8f3,value=Marek-HP,volatile=false]

Exception in thread "main" java.lang.RuntimeException:
org.snmp4j.agent.DuplicateRegistrationException:
org.snmp4j.agent.DefaultMOContextScope[context=null,lowerBound=1.3.6.1.3.22.
1,lowerIncluded=true,upperBound=1.3.6.1.3.22.2,upperIncluded=false]

       at
org.snmpagent.snmpAgentServer.registerManagedObject(snmpAgentServer.java:177
)

       at
org.snmpagent.snmpAgentClientMain.main(snmpAgentClientMain.java:160)

Caused by: org.snmp4j.agent.DuplicateRegistrationException:
org.snmp4j.agent.DefaultMOContextScope[context=null,lowerBound=1.3.6.1.3.22.
1,lowerIncluded=true,upperBound=1.3.6.1.3.22.2,upperIncluded=false]

       at
org.snmp4j.agent.DefaultMOServer.register(DefaultMOServer.java:279)

       at
org.snmpagent.snmpAgentServer.registerManagedObject(snmpAgentServer.java:173
)

       ... 1 more

 

With the information that the content was registered at OID of
1.3.6.1.3.22.1.1 (oidLocalHostName) with the default context (null). The
attempt to perform registration for OID of 1.3.6.1.3.22.2 causes the
org.snmp4j.agent.DuplicateRegistrationException for some reason. I looked
through the documentation associated with this error, but cannot still
locate what the problem is. Any hints?

 

Also, is there a better / cleaner way to create a number of OIDs with
specific values? I looked through the examples in the SampleAgent class, but
there is no clear example of how that could be done. 

 

Thanks for any help 

 

Marek




More information about the SNMP4J mailing list