JMX probes

Those probes connects to any JVM with JMX actived to collect info. It can then collect any values accessible in MBeans than can be reach using a simple path declaration. The path loosely follow the idea given in RESTful Access to JMX Instrumentation

JMXConcMarkSweepGC, JMXParallelGC and JMXSerialGC all collects JVM memory info, see individual documentation to see which one to choose.

An easy (but not very secure) way to activate JMX access on a JVM is to add the following arguments :

-Dcom.sun.management.jmxremote -Dcom.sun.management.jmxremote.port=8999 -Dcom.sun.management.jmxremote.authenticate=false -Dcom.sun.management.jmxremote.ssl=false

A lot of usefull informations about JMX can be found at Jean-Francois Denise's blog

The home page for JMX at Oracle is http://www.oracle.com/technetwork/java/javase/tech/javamanagement-140525.html. JMX is part of JDKM (Java Dynamic Management Kit). The home page of OpenDMK is https://opendmk.java.net. A complete document for the latest version of JDMK is http://docs.oracle.com/cd/E19698-01/816-7609/.

The connection

JMX probes are connected probes

The connection class for this probe is jrds.probe.JMXConnection.

Attributes

Name Default value Description
port The jxm connection port
protocol rmi The protocol used for the jmx connection
user A user for connection authentication
password A password for connection authentication

JMX Protocols

JMX can use different protocol to carry requests. The default one is RMI, but it can be really difficult to use it through firewall and NAT. The simpler jmxmp can be used instead. There is not a lot informations about it, but it's described on this blog. To use it, one needs to put jmxremote_optional.jar it the class path. This jar is include in the JMX Remote API Reference Implementation, that can be downloaded at http://www.oracle.com/technetwork/java/javase/tech/download-jsp-141676.html (or what ever place Oracle choose to move it). An alternate solution it to use opendmk_jmxremote_optional_jar.

To make this protocol always available on Linux hosts using alternatives, this jar can be put in /etc/alternatives/jre/lib/ext. For jrds using tomcat6, the jar should be installed in /usr/share/java/tomcat6/.

Jolokia

Both RMI are brittle, heavy and complicated protocols. Using Jolokia is recommended. It needs a little setup on remote side, that is explained at Jolokia's Agents. The parameter serializeException should be set to true.

If deployed using war, it's as simple as adding the following file in /etc/tomcat/Catalina/localhost/jolokia.xml

<Context cookies="false"
         displayName="jolokia"
         docBase="/path/to/jolokia-war-1.3.4.war"
         >
	<Parameter name="serializeException" value="true"/>
</Context>

And a host configuration to use it will be:

<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!DOCTYPE host PUBLIC "-//jrds//DTD Host//EN" "urn:jrds:host">
<host name="tomcatserver" dnsName="tomcatserver">
    <!-- Tomcat -->
    <connection type="jrds.probe.JMXConnection" name="tomcat">
        <attr name="port">8443</attr>
        <attr name="protocol">jolokia</attr>
        <attr name="ssl">true</attr>
    </connection>
    <probe type="JMXParallelGC8" label="tomcat" connection="tomcat"/>
    <probe type="JMXThread" label="tomcat" connection="tomcat"/>
    <probe type="TomcatGRP" label="tomcat" connection="tomcat">
        <attr name="index">ajp-bio-8009</attr>
    </probe>
</host>

Garbage Collector choice

A Sun JVM can used different code of GC algorithm. In Java 7, the following arguments is used to choose the GC and it gives the probe to used.

Parameter Probe name
-XX:+UseSerialGC JMXSerialGC
-XX:+UseConcMarkSweepGC JMXConcMarkSweepGC
-XX:+UseParNewGC To be done
-XX:+UseParallelGC JMXParallelGC
-XX:+UseParallelOldGC JMXParallelGC
-XX:+UseG1GC G1GC8 (Only for Java8)

If not GC is given, the GC used and the probe to used is given by looking in java.lang:type=GarbageCollector

name=Copy name=MarkSweepCompact JMXSerialGC
name=ParNew name=ConcurrentMarkSweep JMXConcMarkSweepGC
name=ParNew name=MarkSweepCompact To be done
name=PS Scavenge name=PS MarkSweep JMXParallelGC
name=G1 Young Generation name=G1 Old Generation G1GC8 (Only for Java8)

Java 8 removed Permanent generation, so all previous probes are unusable with it. The only supported probed supported for now with Java 8 are JMXParallelGC8 and JMXConcMarkSweepGC8.

 
sourcetype/jmx/start.txt · Last modified: 2017/11/02 12:25 by root     Back to top