This page describes how the SNMP4J-Agent MOFactory concept can be used to apply customised columnar objects to SNMP table implementations.
This guide assumes that you have generated your MIB instrumentation code with AgenPro, but you can do the same with manual written code too.
Generate the MIB module instrumentation code with AgenPro and activate factoryColumn property (set its value to yes) for your entire MIB module (or all affected tables). This will create the code to create MOColumn
instances for read-only columns using the MOFactory
provided to your MIB module.
This step is important, because we will create our own MOFactory
implementation to create our own MOColumn
subclasses.
The generated code for each table will look like (sample taken from the NotificationLogMib.java
):
private void createNlmConfigLogEntry(MOFactory moFactory) { // Index definition nlmConfigLogEntryIndexes = new MOTableSubIndex[] { moFactory.createSubIndex(oidNlmLogName, SMIConstants.SYNTAX_OCTET_STRING, 0, 32) }; nlmConfigLogEntryIndex = moFactory.createIndex(nlmConfigLogEntryIndexes, false); // Columns MOColumn[] nlmConfigLogEntryColumns = new MOColumn[6]; nlmConfigLogEntryColumns[idxNlmConfigLogFilterName] = new MOMutableColumn(colNlmConfigLogFilterName, SMIConstants.SYNTAX_OCTET_STRING, moFactory.createAccess(MOAccessImpl.ACCESSIBLE_FOR_READ_CREATE), new OctetString(new byte[] { })); ValueConstraint nlmConfigLogFilterNameVC = new ConstraintsImpl(); ((ConstraintsImpl)nlmConfigLogFilterNameVC).add(new Constraint(0L, 32L)); ((MOMutableColumn)nlmConfigLogEntryColumns[idxNlmConfigLogFilterName]). addMOValueValidationListener(new ValueConstraintValidator(nlmConfigLogFilterNameVC)); ((MOMutableColumn)nlmConfigLogEntryColumns[idxNlmConfigLogFilterName]). addMOValueValidationListener(new NlmConfigLogFilterNameValidator()); nlmConfigLogEntryColumns[idxNlmConfigLogEntryLimit] = new MOMutableColumn(colNlmConfigLogEntryLimit, SMIConstants.SYNTAX_GAUGE32, moFactory.createAccess(MOAccessImpl.ACCESSIBLE_FOR_READ_CREATE), new UnsignedInteger32(0)); nlmConfigLogEntryColumns[idxNlmConfigLogAdminStatus] = new Enumerated<Integer32>(colNlmConfigLogAdminStatus, SMIConstants.SYNTAX_INTEGER32, moFactory.createAccess(MOAccessImpl.ACCESSIBLE_FOR_READ_CREATE), new Integer32(1)); ValueConstraint nlmConfigLogAdminStatusVC = new EnumerationConstraint( new int[] { NlmConfigLogAdminStatusEnum.enabled, NlmConfigLogAdminStatusEnum.disabled }); ((MOMutableColumn)nlmConfigLogEntryColumns[idxNlmConfigLogAdminStatus]). addMOValueValidationListener(new ValueConstraintValidator(nlmConfigLogAdminStatusVC)); nlmConfigLogEntryColumns[idxNlmConfigLogOperStatus] = moFactory.createColumn(colNlmConfigLogOperStatus, SMIConstants.SYNTAX_INTEGER, moFactory.createAccess(MOAccessImpl.ACCESSIBLE_FOR_READ_ONLY)); ... } |
As you can see in the above code, the moFactory
member of the generated MIB module class is used to create the actual MOColumn
instances. To create our custom MOColumn instances we need our own MOFactory instance first:
Related articles appear here based on the labels you select. Click to edit the macro and add or change labels.
|