Java Dynamic Management Kit 5.1 Tutorial

18.2.4 Running the SNMP Table Instrumentation Example

After you have run mibgen to generate JMX_MBEAN_SERVER_MIB and its associated classes, as explained in 18.2.1 Classes Generated by mibgen, you can run the example.

To Run the SNMP Table Instrumentation Example

Run the example from the examplesDir/current/Snmp/MBeanTable directory.

  1. Compile the Java classes in the generated directory.

    $ cd generated
    $ javac -d .. *.java

    This creates the compiled *.class files into the examplesDir/current/Snmp/MBeanTable directory, rather than in generated, so that they are accessible to the other classes used in the example.

  2. Compile the Java classes in the examplesDir/current/Snmp/MBeanTable directory.

    $ cd ..
    $ javac -d . *.java
  3. Start the Agent.

    You have several options when starting the Agent class.

    • To start the Agent on the default SNMP port, 16161:

      $ java  Agent service:jmx:jmxmp://
    • To start the Agent on a port of your choice:

      $ java  -Dsnmp.port=port_number Agent service:jmx:jmxmp://
    • To start the Agent with a connector of your choosing, you can specify a different service URL and connector port. For example:

      $ java  Agent JMX_service_URL

    In any of the above cases, you see confirmation of the SNMP port used, confirmation of the creation of the connector and then the alternating registration and deregistration of sets of five MBeans.

  4. You can now perform management operations on the Agent.

    Use a JMX management console of your choice to examine the content of the MBean server through a JMXMP connector.

    Use the SNMP management application, easymanager, that is supplied with Java DMK to examine the JMX-MBEAN-SERVER-MIB through SNMP. You can find the easymanager application in the installDir/contributions/easymanager directory.

To Examine JMX-MBEAN-SERVER-MIB Using easymanager
  1. Add the JMX-MBEAN-SERVER-MIBOidTable.class to your classpath.

    Type the following command if you are using a UNIX platform:

    $ export CLASSPATH=$CLASSPATH:examplesDir/current/Snmp/MBeanTable/

    Type the following command if you are using a Windows platform:

    set classpath=%classpath%;examplesDir/current/Snmp/MBeanTable/
  2. Open installDir/contributions/easymanager/bin

  3. Start easymanager.

    If the SNMP agent has been started with the default example port, type the following command.

    $ -port 16161 

    You can now use easymanager to perform the following operations.

    • Pop up a MIB discovery window.

      discovermib -p JDMK_STD_V2_profile
    • Create a new MBean.

      set:2 -w private :<<jmxMBeanObjectName.998,4,Test:name=test1>,
    • Click on resynch in the MIB discovery window to observer the changes in the MIB.

    • Destroy the MBean you created.

      set:2 -w private :<<jmxMBeanRowStatus.998,2,6>>