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.
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.
Subclass the group MBean skeleton you want to implement, and complete the getter, checker, and setter methods.
Subclass the generated MIB file.
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 (_).
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.