JMX discovery

As we saw in the What to monitor? section, it's not always easy to monitor JMX items. As an example, Java has different garbage collectors and they can even change during the lifetime of the application, as it is the developer who decides what garbage collector fits best. Here, low-level discovery (LLD) comes to the rescue. Instead of creating a template with all possible combinations and seeing unsupported items all over our machines, we just discover what is on our hosts.

Let's go to our host Zabbix Java gateway and discover all garbage collectors:

  1. Go to Configuration | Hosts
  2. Select Java from the Group selection box
  3. Click on Discovery behind the Zabbix Java gateway host
  4. Click on Create discovery rule in the upper-right corner

Let's create our global discovery rule by adding the following:

  • Name: Global JMX Discovery Rule
  • Type: JMX agent
  • Key: jmx.discovery[beans,"java.lang:type=GarbageCollector,name=*"]
  • Update interval: 300s

When ready, click the Add button:

Next, we have to create our discovery item as we only have our global discovery rule. As you can see, we added in the key to discover beans. We could have added attributes here as well.

This is the list of items we can select:

  • Attributes (retrieve JMX MBean attributes, default)
  • Beans (retrieve JMX MBeans)
We could also replace java.lang:type with *:type,the other garbage collectors not under java.lang would also be discovered. Try not to add only an * to do a global search but look for a specific type , such as in our case, garbage collectors, else this will cost you lots of resources.

Time to create our discovery item; let's go to Item prototypeCreate item prototype. Add the following parameters in our item:

  • Name: java.gc {#JMXOBJ}-CollectionCount
  • Type: JMX agent
  • Key: jmx[{#JMXOBJ},CollectionCount]
  • Type of information: Numeric (unsigned)
  • New application prototype{#JMXDESC}

Give it some time, then go to Monitoring | Latest data and select Zabbix Java gateway in Host:

As you can see, we now have the latest data for the collection count for our garbage collectors configured on the machine. In our case, the MarkSweepCompact and Copy Garbage Collectors were detected.

Because we added the {#JMXDESC} macro in the new application prototype, we now have a new item in the latest data for every newly-detected JMX object visible like in the preceding screenshot. 

Zabbix maintains a list of supported macros for JMX LLD with a perfect explanation of what every macro does. This information can be found at https://zabbix.com/documentation/4.0/manual/discovery/low_level_discovery/jmx#supported_macros.

Since Zabbix 4.0.0, it's possible to work with custom MBeans that return non-primitive data types, which override the toString() method.
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.222.35.77