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

10.3 Example to Monitor a JMX Value

VERSION 3  Click to view document history
Created on: Aug 10, 2010 5:43 PM by Zenoss API - Last Modified:  Aug 10, 2010 5:59 PM 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.

To configure the system with a custom data source:

  1. Select Infrastructure from the navigation bar.

  2. Click the device in the device list.

    The device overview page appears.

  3. Expand Monitoring Templates in the left panel, and then select Device.

  4. Select Add Local Template from the Action menu.

    The Add Local Template dialog appears.

  5. Enter a name for the template (such as JVM Values), and then click Submit.

    The template is added.

  6. Select the newly created template.

  7. Click (Add) in the Data Sources area.

    The Add Data Source dialog appears.

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

    The data source is added.

  9. Double-click the data source to edit it. Change options as needed, and then click Save.

     

    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


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

    1. Select Add Data Point from the Action menu.

      The Add Data Point dialog appears.

    2. Enter the name of the data point (committed, max, or used) and then click Submit.

  11. After adding all data points, add graphs that reference them. (For more information, see Zenoss Administration.)

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 (1)