To run the mibgen tool for our example, go to the examplesDir/Snmp/Agentdirectory and enter the following command:
$ mibgen -d . mib_II_subset.txt |
This will generate the following files in the current directory:
The MBean (by inheritance) for the whole MIB: RFC1213_MIB.java
The MBean and its metadata class for the Snmp group: Snmp.java, SnmpMBean.java, SnmpMeta.java
The MBean and its metadata class for the System group: System.java, SystemMBean.java, SystemMeta.java
The MBean and its metadata class for the Interfaces group: Interfaces.java, InterfacesMBean.java, InterfacesMeta.java
The class representing an interface table, and the MBean representing entries in the table: TableIfTable.java, IfEntry.java, IfEntryMBean.java, IfEntryMeta.java
Classes representing enumerated types used in these groups and entries: EnumSnmpEnableAuthenTraps.java, EnumIfOperStatus.java, EnumIfAdminStatus.java, EnumIfType.java
The OID table for representing the name definition of all MIB variables: RFC1213_MIBOidTable.java
The MBean with the name of the MIB is just a central administrative class for managing the other MBeans which implement the MIB. All of the other MBeans contain the SNMP variables as attributes of their management interface. The mibgen tool generates standard MBeans for the MIB, so attributes are implemented with individual getter and setter methods.
These MBeans are just skeletons, meaning that the attributes do not do anything. You must implement the getters and setters of the attributes to read and write data with the correct semantic meaning of the SNMP variable.
Since SNMP does not support actions in MIBs, the only operations in these MBeans are checkers for implementing the SNMP set request in writeable variable. You may add operations and expose them in the MBean interface, but the SNMP manager will not be able to access them. However, other managers will be able to call these operations if they are connected through another protocol.