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.
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:
Select Infrastructure from the navigation bar.
Click the device in the device list.
The device overview page appears.
Expand Monitoring Templates in the left panel, and then select Device.
Select Add Local Template from the Action menu.
The Add Local Template dialog appears.
Enter a name for the template (such as JVM Values), and then click Submit.
The template is added.
Select the newly created template.
Click (Add) in the Data Sources area.
The Add Data Source dialog appears.
Enter a name for the data source (Heap Memory), select JMX as the type, and then click Submit.
The data source is added.
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
Option Description 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
Add data points named
committed
,max
, andused
:Select Add Data Point from the Action menu.
The Add Data Point dialog appears.
Enter the name of the data point (
committed
,max
, orused
) and then click Submit.
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.