Cacao supports JMX Remote Monitoring and Management

Since a few days Cacao successfully starts OpenJDKs JMX Monitoring and Management Agent if requested to do so. This allows you to remotely connect to Cacao with any JMX-compliant monitoring tool. One of the main responsibilities of this agent is to act as a server for MBeans (managed beans). The JRE provides some basic MBeans which allow out-of-the-box monitoring and management of VM internals. But applications can easily extend the functionality by providing custom MBeans. If you want to learn more about this topic, you should visit OpenJDKs JMX group.

One such JMX-compliant monitoring tool is JConsole which comes bundled with most J2SDK installations. Below you see a JConsole from Apples Java running on my MacOS X workstation connected to Cacao running on a remote Linux machine.

JConsole connected to Cacao

Note that there (still) are some restrictions on the current support:

  1. Some of the VM internal management functions are not yet fully implemented. Those functions are defined by HotSpots JMM interface (the thing called jmm.h). It will take some time and patience until all of them are implemented.
  2. Only OpenJDK provides a reference implementation of the JMX agent, so at the moment there is no support for GNU Classpath.
  3. The thing that baffled me most, was that the documentation stated that applications running on the same machine inside another HotSpot VM process can be monitored without starting the JMX agent. I found out that HotSpot creates a shared memory region to which you can attach another VM process. I don’t like the idea of sharing memory across VM processes at all, so Cacao does not (and probably never will) support this feature. But I implemented the necessary stubs to avoid UnsatisfiedLinkageErrors and make everything run smoothly. So don’t wonder if you can’t see a list of locally running Cacao processes in JConsole. If you are interested, all the functionality to access this shared memory is hidden in sun.misc.Perf.

And finally, how do you make Cacao start the JMX agent? Try the snippet below. If you want to know more about those magic properties, try one of the thousand other articles out there dealing with this topic.

$ java -Dcom.sun.management.jmxremote \
       -Dcom.sun.management.jmxremote.port=9999 \
       -Dcom.sun.management.jmxremote.authenticate=false \
       -Dcom.sun.management.jmxremote.ssl=false

Have fun monitoring and managing!