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
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:
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:
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:
Problem with dots
So far so good. But what if an attribute name or a hash key contains dot symbol? Here is an example:
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:
Now your item is supported! 🙂
Same way, if your hash key contains a dot you escape it:
A backslash character should be escaped as well:
If the object name or attribute name contains spaces or commas, double-quote it:
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.