[SNMP4J] Adding static scalars to SNMP4J-Agent

Arnoud Zwemmer arnoud.zwemmer at avinity.net
Wed Nov 8 18:21:43 CET 2006


Hi Frank,

I see IfMib.java does exactly this when creating ifNumber in the
constructor, not initializing it with a value yet. I guess my question
for the ifNumber sample case is also how do I set it from Agent.java,
which is where the ifEntry's are populated in a static way. As it's in
Agent.java that the entries are populated, it would seem correct to
populate ifNumber there as well. 

Is your answer the same in that case? Because it seems like ifNumber is
already created then; it only needs to be populated with a static value
(because the constructor did not initialize it). 

But possibly I haven't figured the structures quite yet.

Thanks,

Arnoud.


-----Original Message-----
From: Frank Fock [mailto:fock at agentpp.com] 
Sent: Wednesday, November 08, 2006 5:54 PM
To: Arnoud Zwemmer
Cc: snmp4j at agentpp.org
Subject: Re: [SNMP4J] Adding static scalars to SNMP4J-Agent

Hi Arnoud,

This task is really simple, just use the

  MOScalar createScalar(OID id, MOAccess access, Variable value)

method of the DefaultMOFactory and then
register the returned MOScalar with MOServer.register:

DefaultMOFactory moFactory = new DefaultMOFactory(); MOScalar
myStaticScalar =
   moFactory.createScalar(oidIfNumber0, AccessImpl.ACCESS_READ_ONLY,
                          new Integer32(1/*ifNumber*/));
moServer.register(myStaticScalar, null);

Best regards,
Frank


Arnoud Zwemmer wrote:
> Hi,
>  
> I'm trying to understand how to add MIBs to the SNMP4J-Agent (using 
> generated code). The ifMIB sample provides a sample of adding static 
> rows to the ifTable. I was wondering what's the correct way to add 
> static scalars, for example ifNumber?
>  
> Thanks,
> 
> Arnoud.
>  
> _______________________________________________
> SNMP4J mailing list
> SNMP4J at agentpp.org
> http://lists.agentpp.org/mailman/listinfo/snmp4j

-- 
AGENT++
http://www.agentpp.com
http://www.mibexplorer.com
http://www.mibdesigner.com




More information about the SNMP4J mailing list