Monitoring JBoss AS start with JMX

1 Comment

As my colleague Robert described in his article “How to automate OpenCms module import” we set up an automatic deployment process for one of our projects. However, we experienced some trouble with our way to check whether the app server finished starting up. We were using a simple grep command to observe the server log and it sometimes failed for no apparent reason:

until tail -n 1 server.log | grep "Started"; do sleep 0.01; done

We wanted to find a better way for solving this issue. I only overheard the conversation passing by, but I didn’t get it out of my head even after hours …

For we are using a JEE compliant server (JBoss) I wanted to probe JMX for it is the designated monitoring interface. I was about to write a little JMX client that probes the desired MBean, but while fiddling with the issue I came across an even easier solution: JBoss offers a little helper out of the box that is up to the task in no time and saved me a late night coding session. It’s a little tool called twiddle:

JBoss’ description is self-explanatory:

“A JMX client to ‘twiddle’ with a remote JBoss server.”

Just what we needed! Now we only had to decide which MBean to probe. As “are u there?” is one of the most basic things to ask for this wasn’t too hard either: get jboss.system:type=Server Started

As soon as this returns true the server is up and running.

Robert immediately pimped our little script accordingly:

function twiddleTheBoss {
    echo ` get "jboss.system:type=Server" Started | \
        awk -F "=" '{ print $2 }'`
local STARTED="starting"
until [ $STARTED == "true" ]; do
    sleep 20s

Easy and reliable, just what we wanted 🙂


  • Pietro Aragona

    9. October 2010 von Pietro Aragona

    Thanks Nick, this it is very useful for me, I’m looking for it. I’ll try it asap.


Your email address will not be published.