Monitoring JMX items

Let's create a separate host for JMX monitoring:

  1. Navigate to Configuration | Hosts and click on Create host
  2. Enter Zabbix Java gateway in the Host name field, clear everything in the Groups box, enter Java in the Groups field, and then select Java (new)
  3. Remove the default agent interface and click on Add next to JMX interfaces

In our case, the gateway is running on the localhost, so we can leave the IP address as the default, 127.0.0.1. But what about the port? We had the Java gateway listen on 10052, but then there was also port 12345 in the startup.sh script. If any confusion arises, we should think about which functionality is available on each of these ports. On port 10052, we had the gateway itself, which was the port Zabbix server connects to. We already saw this port set in the server configuration file. Normally, the gateway would then connect to some other Java application to query JMX information:

Port 12345 was in the lines we uncommented in the gateway's startup.sh script, and that was the JMX interface for the gateway. That was also what we wanted to monitor—our Java application. After the Zabbix server connects to the Java gateway on port 10052, we expect the gateway to connect to itself, on port 12345:

Thus, in the host interface, we would want to use port 12345 and surprise—that is also the default:

The JMX system can actually return a different IP address and port that the JMX querying client should connect to. Zabbix uses Java functionality that automatically obeys this information, but in some cases, it can be wrong. If you see error messages and the Zabbix Java gateway seems to connect to a different address or port than the one configured in the host properties, check the configuration of the target Java application, specifically the Djava.rmi.server.hostname and Dcom.sun.management.jmxremote.rmi.port parameters.

The rest of the host configuration should be sufficient for our need—click on the Add button at the bottom. Now, make sure Java is selected in the Group drop-down, click on Items next to Zabbix Java gateway, and click on Create item. Enter the following data:

  • Name: Used heap memory
  • Type: JMX agent
  • Key: jmx[java.lang:type=Memory,HeapMemoryUsage.used]
  • Units: B

When done, click on the Add button at the bottom. Check this item in the latest data section after a few minutes—it should be collecting values successfully.

..................Content has been hidden....................

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