Sun Microsystems
Products & Services
 
Support & Training
 
 

Previous Previous     Contents     Index     Next Next

1.3.1 Advanced mibgen Options

Advanced mibgen options are specified with a -X prefix, as shown in the following list.

mibgen -X:advanced options mib files

-X:advanced options includes the following options.

-X:define

Defines a valid mibgen property in the form name=value

-X:use-display-hint[:on|:off]

Uses DISPLAY-HINT.

When on, this option instructs mibgen to generate an attribute of type String for any object using a textual convention whose DISPLAY-HINT is 255a [com.sun.jdmk.tools.mibgen.options .use.display.hint=true]

-X:abstract-mib[:on|:off]

Generate abstract MIB.

When on, this option instructs mibgen to generate an abstract MIB. The MIB class is an abstract class when the MBean factory methods are abstract. [com.sun.jdmk.tools.mibgen.options .mib.factory.abstract=true]

-X:no-table-access[:on|:off]

No table accessor.

When on, this option instructs mibgen not to generate any table accessors in the group of MBean interfaces. [com.sun.jdmk.tools.mibgen.options .mbean.table.accessor=false].

-X:use-unsigned-long[:on|:off]

Handles unsigned long values.

-X:target:5.0

Generates MIBs compatible with the Java DMK 5.0 implementation of SNMP.

-X:help

Print this help message.

1.4 Output From the mibgen Compiler

The mibgen compiler also generates the Java source code that is required for representing a whole MIB in an SNMP manager. The mibgen compiler parses an SNMP MIB and generates the following.

  • For agents and managers:

    • A class mapping symbolic names with object identifiers of MIB variables

  • For agents:

    • An MBean that represents the whole MIB

    • Classes that represents SNMP groups or entities as MBeans and their corresponding metadata classes

    • Classes that represents SNMP tables

    • Classes that represents SNMP enumerated types

MBeans generated by the mibgen compiler need to be updated to provide the definitive implementation. For more information, see the corresponding section in the Java Dynamic Management Kit 5.1 Tutorial.

1.4.1 Representation of the Whole MIB

The mibgen compiler generates a Java file that represents and initializes the whole MIB. This class extends the class SnmpMib. SnmpMib is an abstract Java class in the com.sun.management.snmp.agent package and is a logical abstraction of an SNMP MIB. The SNMP adaptor uses the SnmpMib class to implement agent behavior. The generated MIB file offers factory methods for group MBeans.

ProcedureTo Implement the Generated MIB File

  1. Subclass the group MBean skeleton you want to implement, and complete the getter, checker, and setter methods.

  2. Subclass the generated MIB file.

  3. Redefine the factory methods for the group MBeans you have implemented, and ensure that they instantiate the actual implementation class and not the skeleton.

The mibgen compiler uses the module name specified in the MIB definition to name files representing whole MIBs. The compiler removes special characters and replaces them with an underscore character (_).

1.4.2 Representation of the Whole MIB in an SNMP OidTable

The mibgen compiler generates a Java file that contains the code required to represent a whole MIB in an SNMP manager OidTable. This class extends the com.sun.management.snmp.snmpOidTableSupport class, which implements the com.sun.management.snmp.snmpOidTable class and maintains a database of MIB variables. A name can be resolved against the database. This file can be used by both the agent and the manager API and contains metadata definitions for the compiled MIB. The metadata can then be loaded into the SnmpOid table.

The file is always generated when mibgen is invoked. The generated file is called MIBnameOidTable. The -mo option generates only the MIBnameOidTable file. This file is the only file generated for SNMP managers. All other files are dedicated to the SNMP agents.

1.5 Classes Representing SNMP Groups

For each SNMP group defined in the MIB, the mibgen compiler generates:

  • A skeletal MBean, with its interface

  • A metadata file

1.5.1 Skeletal MBeans Representing Groups

The mibgen compiler generates an MBean for each group that is defined in the MIB. These skeletal MBeans need to be completed by adding implementation-specific code, to provide access methods. The generated code is initialized with default values for the various MIB variables. If the MIB specifies a default value for an SNMP variable, this value is used to initialize the corresponding variable in the MBean skeleton. Therefore, if you compile the generated code directly, you obtain a running agent. In this case, values returned by the agent when querying the MIBs will be default values or meaningless values, if no default value has been provided in the MIB file for the variable.

The mibgen compiler uses the group names specified in the MIB definition to name MBeans that are generated from groups.

1.5.2 Metadata Files

In addition to generating skeletal MBeans to represent each group, the mibgen compiler generates a metadata file. The metadata file contains Java source code that provides the SNMP view of the MBean. Metadata files do not need to be modified. For metadata files, the Meta suffix is added.

1.6 Classes Representing SNMP Tables

For each SNMP table defined in the MIB, the mibgen compiler generates:

  • A class that contains the view of the table

  • A metadata file that corresponds to the SNMP table

  • A skeletal MBean that represents a table entry, with its interface

  • A metadata file that corresponds to the skeletal MBean

Previous Previous     Contents     Index     Next Next