[SNMP4J] SNMP4J Agen Pro Generation
Frank Fock
fock at agentpp.com
Mon May 29 20:55:25 CEST 2006
Hello Ron,
Ron Fulkerson wrote:
> Hello All,
>
> I have a number of questions about using snmp4j along with the Agen Pro
> code generator. I hope someone here will not mind giving a bit of their
> time to enlighten me of some good resources to help me get started.
>
Just a small info beforehand: AgenPro 2.5 which will be released
on 12. June will include a instrumentation How-To for the stub
code generated for SNMP4J-Agent.
> I am looking for a resource which explains how to work with the code
> generated by Agen Pro v 2.1. Specifically, I would like to see an
> example of working with dynamic tables and values with read-write access.
>
> The code generated by Agen Pro produces stubs to override, including one
> for isValueOK() and a ValidationListener. These two stubs seem to be
> redundant in their purpose. The generated code also produces a stub for
> get(), yet I do not see the rational for overriding the default
> implementation.
In v2.5 AgenPro will provide an option where you can choose to
overwrite isValueOK or to use a ValidationListener. These two
concepts can be used alternatively. The second approach is
recommended when the ManagedObject can be implemented without
extending SNMP4J-Agent MO* classes.
The rational to overwrite the get() method is to be able to
update the internal value of a ManagedObject when its value
is being requested.
>
> Also, I am not sure I understand the rational behind making each OID in
> the generated code private. These values seem like they are needed in
AgenPro v2.5 will generate "public" constants by default, but that
can be configured for each object/sub-tree individually.
> creating a notification originator. I would think referencing a public
> instance of these values would be the best approach when creating this
> class.
>
> I understand that I can change the generation templates to produce
> whatever I would like, but I assume these templates were modeled after
> SNMP best practices. It is my desire to understand these practices and
> follow their guidelines. Any pointers in this area would be great.
It depends on how such a MIB module implementation is used.
When it is used in combination with other MIB modules a public
constant is useful, otherwise it might be better to hide
the (then) internal constants.
>
> Finally, I have not yet figured out how to populate the tables the are
> created in the generated code. Any pointers in this area would be much
> appreciated.
To populate a MOTable you can use the following scheme:
MOTable table = new DefaultMOTable(...);
OID newIndex = indexVariable.toSubIndex(false);
MOTableRow newRow = table.createRow(newIndex);
// probably change some column values
...
table.addRow(newRow);
Hope that helps.
Best regards,
Frank
--
AGENT++
http://www.agentpp.com
http://www.mibexplorer.com
http://www.mibdesigner.com
More information about the SNMP4J
mailing list