Friday, June 1, 2012

Using jconsole

 jconsole is a graphical application shipped in JDK 5. It is a monitoring tool for the JVM. Features include:
  1. Heap memory monitoring
  2. Threads monitoring
  3. CPU usage monitoring
  4. Number of loaded classes
  5. JMX: accessing MBeans registered to the MBean server of the JVM
It is possible to connect to any local JVM by launching jconsole (e.g. via command line command "jconsole").

However, to connect to a remote JVM, the JVM needs to be started with options that enables the RMI server for JMX.

"-Dcom.sun.management.jmxremote -Dcom.sun.management.jmxremote.port=XXXX -Dcom.sun.management.jmxremote.ssl=false -Dcom.sun.management.jmxremote.authenticate=false -Djava.rmi.server.hostname=XXXXXXX"

In the case of Tomcat, add the following lines to setenv.sh

CATALINA_OPTS="-Dcom.sun.management.jmxremote -Dcom.sun.management.jmxremote.port=XXXX -Dcom.sun.management.jmxremote.ssl=false -Dcom.sun.management.jmxremote.authenticate=false -Djava.rmi.server.hostname=XXXXXXX"
export CATALINA_OPTS 

To enable password security, add the following options:
"-Dcom.sun.management.jmxremote.password.file=XXXXXX -Dcom.sun.management.jmxremote.access.file=XXXXXXX"

and change "-Dcom.sun.management.jmxremote.authenticate=false" to "-Dcom.sun.management.jmxremote.authenticate=true"

The password file should look something like:
jmxuser password

The access file should look something like:
jmxuser readwrite

No comments:

Post a Comment