This module exposes some system monitoring data using Java Management Extensions (JMX) and provides an easy framework for other modules to publish objects using JMX.
Tomcat can be launched with it's own JMX bean server. To do this add the following to the start of catalina.sh:
This will create a JMX bean server with no authentication. This SHOULD ONLY be done for development servers.
For a production server you can specify a password file and/or SSL requirements.
Once you have configured Tomcat to use JMX, restart it, login to OpenMRS and install the JMX module.
The JRE comes bundled with a simple JMX viewer called jconsole. You can use this to connect to the Tomcat JMX server and view the OpenMRS beans as well as the other Tomcat diagnostic beans.
Other modules can use this module to easily publish JMX management beans (called MBeans). The bean will be published as part of the same domain and host as the other beans. For example, the Usage Statistics Module publishes a bean which appears like this:
There are several ways to define an MBean. The easiest is to define an interface that uses the @MXBean annotation, e.g.
...and a class which implements that interface, e.g.
In your module activator you can then register an instance of the bean with the JMX module when your module is started, e.g.
...and unregister it when it shuts down, e.g.
Usually you will want to access OpenMRS services to get the values of your bean properties. This requires a valid OpenMRS session with the correct privileges for those service methods. To make this easier, the JMX module defines an annotation which will wrap the method call in a temporary OpenMRS session with the requested privileges, e.g.
Project code is hosted on github at https://github.com/rowanseymour/openmrs-module-jmx