Blogs
Monitoring JMX data has been always a painful process, especially in production systems where the ability to open ports and/or allow certain kind of traffic is kind of "complicated".
Thanks to Jolokia we have a lightweight layer on top of the MBean Server infrastructure which allows to query our JMX data over the http protocol. The architecture is very simple:

I have borrowed the previous image from this presentation where you can see a great overview of the Jolokia's benefits.
How can I use it in Liferay?
The Jolokia guys have an OSGi bundle ready to be deployed inside an OSGi container. The only dependency of the previous bundle is that an Http Service implementation should be available within the container, but this is not a problem since we already provide our own implementation fo the previous specification (it will be bundled by default from 6.2.0 and above). The provided bundle needs a small modification which I have already done for this blog entry and you can get here ( I need to do it configurable, but for the purpose of this post we are fine with this artifact).
Get the previous bundle and copy it to your deploy folder; in a few seconds your bundle will be deployed into the OSGi container and you will have a fully working http layer on top of your JMX data.
Querying some data
There are a few clients you can use to query the data through this Http layer (even if you want, you can write your own :) ):
-
http://hawt.io/ Nice HTML5 extensible dashboard with many available plugins
-
j4psh: Unix like shell with command completion
-
jmx4perl: CLI tool for scripting
-
check_jmx4perl: Nagios plugin
-
AccessJ: and iPhone client
Let's see an small example of how to use the j4psh shell:
First of all we need to connect to our server

As I have told you before the current bundle is not configurable and you should use the /o/jolokia/jolokia path (hope this is not a big deal for you). Once we are connected we can navigate through our JMX data (j4psh structures the info using a a "file system approach").
For example, if we type ls, we can see something like this:

Or we can search for a certain info and get the current value, for example the number of total loaded classes into the JVM

As you can see this is an extremely powerful and lightweight tool we can use to monitor our data in a very simple way.
I will try to clean-up a little bit the bundle used in this post in order to make it configurable and I will try to publish it in a more accessible place.
See you soon!

