Enable JBoss remote JMX monitoring in Zabbix

In a previous blogpost about Zabbix and JBoss monitoring I’m using remote JMX to pull data from the JBoss server and store it in Zabbix. In this post I’ll describe how to enable this.

NOTE: Working in a testing environment I didn’t do anything with regards to security. Enabling this will let any host in the network fetch JMX data from the server.

First, my environment:

  • Zabbix Server 2.2.1 zabbix.kanbier.lan
  • JBoss Server EAP 5.2.0 jboss.kanbier.lan
  • Both servers running Red Hat Enterprise Linux 6.5

Enable remote JMX monitoring

For testing purposes I’m installing my JBoss software in /opt/jbossas. I downloaded the binary package and unzipped it there.

To enable remote JMX monitoring you have to configure it in the run.conf file. In my example I’m going to enable JMX monitoring on port 9999, without any form of security.

Open:

/opt/jbossas/jboss-as/bin/run.conf

And add at the bottom of this file (replace the <YOUR_JBOSS_SERVER_IP> with your JBoss server IP):

# JMX Remote Management configuration
JAVA_OPTS=”-Dcom.rmi.server.hostname=<YOUR_JBOSS_SERVER_IP> $JAVA_OPTS”
JAVA_OPTS=”-Dcom.sun.management.jmxremote $JAVA_OPTS”
JAVA_OPTS=”-Dcom.sun.management.jmxremote.port=9999 $JAVA_OPTS”
JAVA_OPTS=”-Dcom.sun.management.jmxremote.authenticate=false $JAVA_OPTS”
JAVA_OPTS=”-Dcom.sun.management.jmxremote.ssl=false $JAVA_OPTS”
JAVA_OPTS=”-Djboss.platform.mbeanserver $JAVA_OPTS”
JAVA_OPTS=”-Djavax.management.builder.initial=org.jboss.system.server.jmx.MBeanServerBuilderImpl $JAVA_OPTS”

After saving the file, start the JBoss server with the “-b” option:

/opt/jbossas/jboss-as/bin/run.sh -b <YOUR_JBOSS_SERVER_IP>

This should enable remote JMX monitoring for your JBoss instance. Let’s check if this is really working by doing a remote query from the Zabbix server.

To do so we’re going to need a command line utility that let’s us query JMX servers. There are a couple of options available on the internet, but the only one that worked well for me was cmdline-jmxclient-0.10.3.jar.

Being a .jar file you’re going to need Java. I assume you’ve got that installed.

Download the cmdline-jmxclient to the Zabbix server, and execute this to do a remote query to the JBoss server  (this is one line):

java -jar cmdline-jmxclient-0.10.3.jar -:- jboss.kanbier.lan:9999 jboss.messaging.destination:name=ExpiryQueue,service=Queue JNDIName

Result:

01/13/2014 18:56:57 +0100 org.archive.jmx.Client JNDIName: /queue/ExpiryQueue

There we go, we queried the JMX server from the Zabbix server and got a response. Remote JMX monitoring is working. Let’s get these values into Zabbix.

JMX monitoring in Zabbix

JMX monitoring in Zabbix requires the zabbix-java-gateway component. Since I’m running RHEL and have the Zabbix repository enabled I can install it this way:

# yum install zabbix-java-gateway

It’s default configuration is fine. Let’s start it and make sure it starts across reboots:

# service zabbix-java-gateway start
# chkconfig zabbix-java-gateway on

Configure the Zabbix server to automatically start 5 java pollers when zabbix starts:

Open:

/etc/zabbix/zabbix_server.conf

Add these parameters:

JavaGateway=<IP_OF_ZABBIX_SERVER>
StartJavaPollers=5

Restart Zabbix:

# service zabbix-server restart

Zabbix is now able to perform remote JMX queries.

Leave a Reply

Your email address will not be published. Required fields are marked *