Introduction
JMX monitoring with Zabbix is easy using Zabbix Java gateway. Let’s say you have a JMX-enabled Java application running on some host. You start the Java gateway, configure Zabbix server to use that, add that host in Zabbix frontend, set up a JMX interface and create a JMX agent item (described here). A JMX item key name is (surprise-surprise!) jmx and it needs 2 parameters that describe a monitored entity:
- an MBean object name
- an MBean attribute name
Simple attributes
An object name is nothing but a string, which you define in your Java application. An attribute name, on the other hand, can be more complex. In case an attribute returns primitive data type (an integer, a string etc.) there is nothing to worry about, the key will look like this:
jmx[com.example:Type=Hello,weight]
In this example an object name is com.example:Type=Hello, attribute name is weight and probably the returned value type should be Numeric (float).
Attributes returning composite data
It becomes more complicated when your attribute returns composite data. For example: your attribute name is apple and it returns a hash representing its parameters, like weight, color etc. Your key may look like this:
jmx[com.example:Type=Hello,apple.weight]
This is how an attribute name and a hash key are separated, by using a dot symbol. Same way, if an attribute returns nested composite data the parts are separated by a dot:
jmx[com.example:Type=Hello,fruits.apple.weight]
Problem with dots
So far so good. But what if an attribute name or a hash key contains dot symbol? Here is an example:
jmx[com.example:Type=Hello,all.fruits.apple.weight]
That’s a problem. How to tell Zabbix that the attribute name is all.fruits, not just all? How to distinguish a dot that is part of the name from the dot that separates an attribute name and hash keys?
Before 2.0.4, Zabbix Java gateway was unable to handle such situations and users were left with UNSUPPORTED items. Since 2.0.4 this will be possible, all you need to do is escape the dots that are part of the name with a backslash:
jmx[com.example:Type=Hello,all\.fruits.apple.weight]
Now your item is supported! 🙂
Same way, if your hash key contains a dot you escape it:
jmx[com.example:Type=Hello,all\.fruits.apple.total\.weight]
Other issues
A backslash character should be escaped as well:
jmx[com.example:type=Hello,c:\\documents]
If the object name or attribute name contains spaces or commas, double-quote it:
jmx["java.lang:name=ConcurrentMarkSweep,type=GarbageCollector","LastGcInfo.memoryUsageAfterGc.CMS Old Gen.committed"]
If you can’t wait till 2.0.4 release you can get the fix from the development branch, which is mentioned in the Zabbix issue-tracking system.
Update: by now the development branch has been merged back to the main branch, so SVN head or nightly snapshots can be used for testing.
JMX monitoring is a pleasure with Zabbix! dimir, you have plans to fix the problem for JBossAS 7.1? => Configurable JMX Endpoint ZBXNEXT-1274
Thanks!
Thanks for mentioning this, Jose. I’ll discuss this with the management when I’m back from vacation. If I forget please bug me on IRC. 🙂
Any word when the License issues with JMX will be addressed and resolved? This is at present limiting Zabbix’s full inclusion (all features except JMX) in EPEL.
https://support.zabbix.com/browse/ZBX-4800
Definitely needs to be resolved ASAP.
What about JMX tabular data and method calls?
Haven’t considered that yet, please open ZBX.
Yes I will do!
This will be fixed here: https://support.zabbix.com/browse/ZBX-23948 (planned for 7.0)