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.
Navigate to the device or device class in the Zenoss web interface.
Click the page menu, then select
→ .Create a performance template by selecting
from the page menu.Enter an identifier for the template (such as
JVM Values
) and then click to create it.Click on the newly created template
JVM Values
.Select Data Sources table menu.
from theEnter a name for the data source (
Heap Memory
), selectJMX
as the type, and then click OK.The Data Source page appears.
Change options as needed.
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
Click
to save your changes.Add data points named
committed
,max
, andused
.Select DataPoints table menu.
from theProvide the name of the data point (ie one of
committed
,max
, orused
) and then click on the button.As the default
GAUGE
is suitable for these data points, click on the to save the data point.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.
Add graphs that reference these new data points. See the Zenoss Administration Guide for more details.
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.