Archived community.zenoss.org | full text search
Skip navigation
Currently Being Moderated

10.3 Example to Monitor a JMX Value

VERSION 1 
Created on: Mar 1, 2010 8:22 AM by Zenoss API - Last Modified:  Mar 1, 2010 8:22 AM by Zenoss API

 3. Example to Monitor a JMX Value

 3.1. Enabling Remote JMX Access

Each application server has a slightly different process for enabling remote JMX Access. It's best to consult with your application server for specific instructions. We've included instructions for a few commonly used configurations below.

JMX agents can be configured in two ways: remote access and local-only. When configured for remote access a JMX client communicates with the JMX agent via a socket and uses the Remote Method Invocation (RMI) protocol to access the MBeans. When configured for local-only access the JMX agent periodically dumps serialized MBeans to a temporary directory on the machine. JConsole can be used to access JMX agents in local-only mode as well as in remote mode (via RMI). ZenJMX can only be used with remote servers via RMI and cannot work with local-only serialized MBeans. This is not a significant limitation because ZenJMX can establish RMI connections to localhost just as easily as it can establish RMI connections to remote hosts.

The JAVA_OPTS environment variable can be used to enable remote access to JVM MBeans. Set it as follows:

JAVA_OPTS="-Dcom.sun.management.jmxremote.port=12345
JAVA_OPTS="${JAVA_OPTS} -Dcom.sun.management.jmxremote.authenticate=false"
JAVA_OPTS="${JAVA_OPTS} -Dcom.sun.management.jmxremote.ssl=false"

export JAVA_OPTS

When starting an application pass the JAVA_OPTS variable as an argument to the JVM as follows:

java ${JAVA_OPTS} -classpath /path/to/application.jar com.yourcompany.Main

You can then use JConsole to connect to localhost:12345. Authentication can be configured by modifying the java.security file as well as java.policy. There are lots of examples available on the Internet that can provide guidance in how to achieve authenticated remote access to JVM MBeans.

 3.2. Configure Zenoss with a Custom Data Source

Custom JMX Data Sources allow system administrators to monitor any attribute or operation result accessible via a JMX call. ZenJMX creates a JMX Data Source and allows you to provide Object information, as well as authentication settings, and attribute/operation information. Determining which object and attribute names, as well as which operations to invoke, is the key to customizing ZenJMX.

  1. Navigate to the device or device class in the Zenoss web interface.

  2. Click the page menu, then select MoreTemplates.

  3. Create a performance template by selecting Add Template from the page menu.

  4. Enter an identifier for the template (such as JVM Values) and then click OK to create it.

  5. Click on the newly created template JVM Values.

  6. Select Add DataSource... from the Data Sources table menu.

  7. Enter a name for the data source (Heap Memory), select JMX as the type, and then click OK.

  8. The Data Source page appears.

    Change options as needed.

     

    Table 10.2. Memory Head Example ZenJMX Data Source Options

    OptionDescription

    JMX Management Port

    This is not necessarily the same as the listen port for your server.

    Object Name

    The Object Name is also referred to as the MBean name. Enter java.lang:type=Memory

    Attribute Name

    Enter HeapMemoryUsage


  9. Click Save to save your changes.

  10. Add data points named committed, max, and used.

    1. Select Add DataPoint... from the DataPoints table menu.

    2. Provide the name of the data point (ie one of committed, max, or used) and then click on the Add button.

    3. As the default GAUGE is suitable for these data points, click on the Save to save the data point.

    4. Click on your browser's back button to return to the template screen and add the next data point. Note that you will need to refresh the browser screen in order to see the newly added data point.

  11. Add graphs that reference these new data points. See the Zenoss Administration Guide for more details.

  12. Navigate to the Perf tab and you should see some placeholders for graphs. After approximately 15 minutes you should see the graphs start to become populated with information.

Please review Section 5, “Using JConsole to Query a JMX Agent” to learn how to determine the object name, attribute name, and data points that might be interesting in your application.

Comments (2)