Sep 22

JRuby + jmx4r + rrd4j == Easy reporting on app servers (part I)

This is a how-to for using jmx and rrd4j, a java implementation of rrdtool, to report on app server statistics.

Thanks to Jeff Mesnil(author of jmx4r), Werner Schuster (JMX the Ruby way with jmx4r), sishen (JRobin sucks), and the rrd4j team.

You’ll need the following:

  1. JVM 1.5 or higher — JRE is not enough, you also need the JDK. Remember to set your JAVA_HOME — JRuby needs it.
  2. JRuby — I’m using 1.1.4. Note: You need to be sure to set the JRUBY_HOME and make sure that ${JRUBY_HOME}/bin comes in $PATH prior to any other ruby installation. Otherwise, your results will be indeterminate.
  3. jmx4r — this is a gem and can be installed by
  4. rrd4j — in order to get this, you need to create an account on java.net. Once you’ve done that, you can download the library via subversion:

    Replace username with your java.net username. You’ll need ant to build it:

    Or you can download the jars: rrd4j jars
  5. An application which responds to jmx queries — this example is using jconsole since it is a standard part of the java distribution in 1.5 and after.

Before we do much else, let’s verify that jconsole is working:

Choose for the port some large nuimber…  Your screen will look something like this for 1.5 (ignore the cutoff bits, I’m writing this on chibi):

Portion of a JConsole screen

Portion of a JConsole screen

Ok, now that we’ve got that going, let’s attempt connecting via jmx4r…

Cool! now we’re making progress!


  1. Jason Jackson

    Also worth noting that if your not connecting to JBoss on localhost, make sure you have DNS set up, or a host file entry, or else you will get an exception returned saying that it failed to connect on The error is a little misleading, as the connection is made to the remote side, and the localhost ip returned in the exception is actually on the remote host.

  2. Shared Frank

    A fully explained article!

    Well done, I found this blog on google and found very intresting.

    Thanks and bookmarked

Leave a Reply

%d bloggers like this: