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

Marek Hajduczenia marek.hajduczenia at gmail.com
Mon Apr 1 11:55:11 CEST 2013


Frank, 

I tried already different OIDs, thinking that this particular one might be
indeed used on the system. I switched to a different OID, which is still
within the experimental range, but should be unused (1.3.6.1.3.1122 - found
no record online of it being used)

			OID oidLocalHostName = new
OID("1.3.6.1.3.1122.1.1"); // nomeServidor 
			OID oidRootFolder = new OID("1.3.6.1.3.1122.1.2");
// diretoriaBase 
			OID oidDefaultPlayer = new
OID("1.3.6.1.3.1122.1.3"); // musicPlayer 
			OID oidNumberOfMusicFiles = new
OID("1.3.6.1.3.1122.1.4"); // nTotalmMsicasDisp

And then tried to create the objects

	
server.registerManagedObject(MOCreator.createReadOnly(oidLocalHostName,
java.net.InetAddress.getLocalHost().getHostName()));
	
server.registerManagedObject(MOCreator.createReadOnly(oidDefaultPlayer,
"VLC"));
	
server.registerManagedObject(MOCreator.createReadOnly(oidRootFolder,
folder.getAbsolutePath()));

getting the duplicate error on the second line. 

Perhaps it is a lame question, but do I need to register 1.3.6.1.3.1122.1
somehow before? I just noticed that I am not really doing that anywhere ... 

Marek

-----Original Message-----
From: Frank Fock [mailto:fock at agentpp.com] 
Sent: Monday, 01 April, 2013 10:47 AM
To: Marek Hajduczenia
Cc: snmp4j at agentpp.org
Subject: Re: [SNMP4J] Registering multiple managed objects and
org.snmp4j.agent.DuplicateRegistrationException error

Hi Marek,

Ok, the experimental sub-tree is indeed something different.
Nevertheless, the DuplicateRegistrationException only occurs,
if another ManagedObject have bee registered for this OID
or any prefix OID of that OID. Somehow, the OID 1.3.6.1.3.22.1
has been already registered.

Best regards,
Frank

Am 01.04.2013 11:35, schrieb Marek Hajduczenia:
> Frank,
>
> There cannot be clash within my own agent. I specifically use the
> experimental branch (1.3.6.1.3) which does not require any formal
> registration as long as it is for testing purposes only. In either case, I
> tried different root locations and the net result is the same -
> DuplicateRegistrationException.
>
> The funny thing is that I can create a table at 1.3.6.1.3.22.2 with no
> problems. It is just the 1.3.6.1.3.22.1 and subbranches that generate this
> kind of problem.
>
> Is there any example piece of code that show how to properly register a
> number of scalar values? I need the following 4 objects to be created:
>
> 			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
>
> Marek
>
> -----Original Message-----
> From: Frank Fock [mailto:fock at agentpp.com]
> Sent: Sunday, 31 March, 2013 11:28 AM
> To: Marek Hajduczenia
> Cc: snmp4j at agentpp.org
> Subject: Re: [SNMP4J] Registering multiple managed objects and
> org.snmp4j.agent.DuplicateRegistrationException error
>
> Hi Marek,
>
> The registration clash occurs in your own agent program.
> You have to acquire your own root OID at the IETF.
> It is called "enterprise registration number".
>
> The root OID of your enterprise is the prefix of each OID you use. For
> AGENT++ it is 1.3.6.1.4.1.4976
>
> Best regards,
> Frank
>
> Am 30.03.2013 17:52, schrieb Marek Hajduczenia:
>> Hi Frank,
>>
>> Thank you for the quick answer.
>>
>> I removed the "dots" from the OID numbers, but the problem still
>> remains. I did not find any standard MIBs that have OID 1.3.6.1.3.22.1
>> so I am not quite sure why there would be a clash here. This is the
>> first time I register the OIDs in my agent and there are no other
>> agents running on my machine that could use this particular OID value.
>>
>> Also, I'd very much appreciate if you could point me to any code that
>> provides the definition of my own OID root. I could not find that in
>> the sample agent code.
>>
>> Thank you in advance
>>
>> Marek
>>
>> -----Original Message-----
>> From: snmp4j-bounces at agentpp.org [mailto:snmp4j-bounces at agentpp.org]
>> On Behalf Of Frank Fock
>> Sent: Saturday, 30 March, 2013 2:37 PM
>> To: snmp4j at agentpp.org
>> Subject: Re: [SNMP4J] Registering multiple managed objects and
>> org.snmp4j.agent.DuplicateRegistrationException error
>>
>> Hi,
>>
>> First, OIDs start with a number, not a dot.
>> Second, you need to register your own OID root. You must not define
>> any OIDs in subtrees of other vendors or standard MIB modules.
>> In your case, your OIDs clash with other OIDs in the agent -> that's
>> why a DuplicateRegistrationException is being thrown.
>>
>> Best regards,
>> Frank
>>
>> Am 30.03.2013 14:35, schrieb Marek Hajduczenia:
>>> 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(oidLocalHostNam
>>> e , java.net.InetAddress.getLocalHost().getHostName()));
>>>
>>> server.registerManagedObject(MOCreator.createReadOnly(oidDefaultPlaye
>>> r , "VLC")); // HERE IS THE LINE WITH ERROR
>>>
>>> server.registerManagedObject(MOCreator.createReadOnly(oidRootFolder,
>>> folder.getAbsolutePath()));
>>>
>>> server.registerManagedObject(MOCreator.createReadOnly(oidNumberOfMusi
>>> c
>>> Files,
>>> 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.a
>>> g ent.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.a
>>> g ent.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.j
>>> a
>>> va: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.j
>>> a
>>> va: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
>>>
>>> _______________________________________________
>>> SNMP4J mailing list
>>> SNMP4J at agentpp.org
>>> http://lists.agentpp.org/mailman/listinfo/snmp4j
>> --
>> ---
>> AGENT++
>> Maximilian-Kolbe-Str. 10
>> 73257 Koengen, Germany
>> https://agentpp.com
>> Phone: +49 7024 8688230
>> Fax:   +49 7024 8688231
>>
>> _______________________________________________
>> SNMP4J mailing list
>> SNMP4J at agentpp.org
>> http://lists.agentpp.org/mailman/listinfo/snmp4j
>>
> --
> ---
> AGENT++
> Maximilian-Kolbe-Str. 10
> 73257 Koengen, Germany
> https://agentpp.com
> Phone: +49 7024 8688230
> Fax:   +49 7024 8688231
>

-- 
---
AGENT++
Maximilian-Kolbe-Str. 10
73257 Koengen, Germany
https://agentpp.com
Phone: +49 7024 8688230
Fax:   +49 7024 8688231




More information about the SNMP4J mailing list