Sun Microsystems
Products & Services
 
Support & Training
 
 

Previous Previous     Contents     Index     Next Next
Chapter 1

SNMP MIB Compiler (mibgen)

The Java Dynamic Management Kit (Java DMK) provides a toolkit for developing SNMP agents and managers. This toolkit includes the SNMP MIB Compiler, mibgen, which is used for compiling SNMP MIBs into Java source code for agents and managers.

This chapter describes how to use the mibgen compiler, in the following sections:

1.1 Overview of the mibgen Compiler

The mibgen tool is a Java technology-based SNMP MIB compiler that takes an SNMP MIB as input and generates a set of Managed Beans (MBeans). These MBeans can be customized to implement the MIBs, enabling the Java DMK agent to be managed by an SNMP manager. You can use standard MBeans, model MBeans, dynamic MBeans and open MBeans in conjunction with the mibgen compiler.

The mibgen compiler is able to process the following:

  • Tables with cross-references that are indexed across several MIBs

  • Nested groups

  • Default value variables

  • Row status, namely tables controlled by a columnar object obeying the RowStatus convention, as defined in RFC 2579.

1.2 Starting the mibgen Compiler

To start the mibgen compiler, type the following command.

prompt% installDir/SUNWjdmk/5.1/bin/mibgen [options] mib1 ... mibN


Note - The script for starting the mibgen tool uses the JAVA_HOME environment variable to determine the path to the Java 2 Platform, Standard Edition (J2SE). Therefore, even if you have the correct path to the J2SE platform in your PATH environment variable, this is overwritten by the JAVA_HOME variable.


1.3 mibgen Options

To invoke the java.com.sun.jdmk.tools.MibGen class, you need to invoke java.com.sun.jdmk.tools.MibGen options mib files.

mibgen options mib files

The options are listed below.

-n

Parses the MIB files without generating code.

-d dir

Generates code in the specified target directory.

-tp pkgName

Generates code within the specified Java package (target package).

-desc

Includes the DESCRIPTION clause of OBJECT-TYPE as comment in generated code.

-mo

(manager-only)

Generates code for the SNMP manager only, namely the metadata file for the MIB variables (SnmpOidTable file). By default, the mibgen compiler generates code for both SNMP agents and managers. By selecting the -mo option, you enable the mibgen compiler to generate code for only the manager and not for agents. The -mo option is incompatible with the -n option.

-mc

(MIB-CORE)

Does not use the default MIB-CORE definitions file provided with Java DMK. In this case, the user must specify the MIB-CORE definitions file as one of the MIB files. For example, java.com.sun.jdmk.tools.MibGen -mc mib my_mib_core.

-a

Generates code for all the MIB files. Without this option, the Java code is generated only for the first MIB file. In this case, the following MIB files are used to resolve some definitions of the first MIB file.

-p prefix

Uses the specified prefix for naming generated classes.

-g

Generates a generic version of the metadata that will access the MBeans through the MBean server instead of using a direct reference. This enables you to plug in dynamic MBeans, instead of the generated standard MBean skeletons.

-gp prefix

Uses the specified prefix to name the generic metadata classes. For example, the metadata class for group System will be named SystemprefixMeta. The default is no prefix.

-sp prefix

Uses the specified prefix to name the standard metadata classes. For example: the metadata class for group system will be named SystemprefixMeta. Default is no prefix.

-help

Prints a usage message explaining how to invoke the compiler, as follows:

<mib files>: By default mibgen generates code only for the modules specified in the first file. The other files are only used for closure analysis except when the -a is specified.

The order followed by the mibgen compiler to find the MIB_CORE definitions file is as follows:

  1. The user MIB_CORE definitions file specified in the MIB files using the -mc mibgen option.

  2. The command line parameter specified using the -Dmibcore.file Java property.

  3. The default MIB_CORE definitions file provided with the Java DMK in installDir/etc/mibgen (mib_core.txt). To succeed, you must be able to derive the installation directory from the CLASSPATH environment variable. Otherwise, the mibgen compiler looks for the mib_core.txt file in currentDir/etc/mibgen.

  4. When using generic metadata (-g option), backward compatibility is not ensured. Using the -g option has generic advantages, whereby MBeans are accessed through the MBean server, any kind of MBeans can be plugged in, but this option slightly reduces the overall performance.


Note - SNMP MIB implementations generated using the mibgen compiler from Java DMK 5.0 can run and recompile on Java DMK 5.1 without modification.


Previous Previous     Contents     Index     Next Next