Saturday, January 17, 2015

Zabbix. JMX monitoring. Working around the "javax.naming.namenotfoundexception: jmxrmi" issue

Aim: to monitor Active MQ queues bundled within Jboss Fuse with Zabbix

But there's a problem:

So what do we do?
Skip the java gateway altogether.

java -jar check_jmx.jar --h
Usage: check_jmx -U  -O  -A 
    [-K ] [-w ] [-c ]
    [-o ] [--username ] [--password ]
    [-u ] [-v] [-h]

We incorporate this jmx client command line utility into the zabbix toolset by creating a user parameter that looks like this:

UserParameter=jmx_query[*],/usr/bin/java -jar /usr/local/bin/nagios_jmx/check_jmx.jar -U  "$1" -O "$2" -A $3 --username $4 --password $5 | grep -oP "\d*" | head -1

Restart the zabbix agent and perform some tests with zabbix_get

For instance:

zabbix_get  -s 10.88.XXX.XXX -I 10.88.XXX.XXX -k 'jmx_query["service:jmx:rmi://IP:44444/jndi/rmi://IP:1099/karaf-FOO","org.apache.activemq:type=Broker,brokerName=FOO,destinationType=Queue,destinationName=FOO.BAR.QUEUE",DequeueCount,myuser,mypassword]'

Tip: if your object definition includes commas, you'll need to set the UnsafeUserParameters = 1 and double quote the parameters that include them.

A very hackish way of doing things, but that's the beauty of openness, you can always hack your way around.
Feel free to post doubts in the comments.