Since Zabbix 2.0, there is native support for monitoring Java applications in Zabbix. For this, Zabbix makes use of a so-called Java gateway. Once the gateway is in place, Zabbix can monitor all JMX counters from our Java application.
For this setup to work, you need as usual, your Zabbix server setup and access with full administration rights. We also need a host configured in Zabbix that we can use to install our JMX and Java application. If you have compiled your server from source, then make sure you have compiled it with the --enable-java
option.
yum install zabbix-java-gateway
chkconfig zabbix-java-gateway on
For RHEL 7:
systemctl enable zabbix-java-gateway
service start zabbix-java-gateway
For RHEL 7:
systemctl start zabbix-java-gateway
zabbix_server.conf
file, change the following options:Java gateway = 127.0.0.1 Java Gateway Port = 10052 Start Java pollers = 2
zabbix-server
:service zabbix-server restart
For RHEL 7:
systemctl restart zabbix-server
zabbix-java-gateway.conf
file as well, where you can specify the same parameters to update this file.java -Dcom.sun.management.jmxremote -Dcom.sun.management.jmxremote.port = 12345 -Dcom.sun.management.jmxremote.authenticate = True -Dcom.sun.management.jmxremote.ssl = True -jar some-java-app.jar
JMX agent
.As you will see, JMX monitoring is not a straightforward thing. Sometimes your application won't connect to the correct IP or a type will refuse the Java to start.
On top of that, installing the JMX console will be a security risk. Luckily enough, we can add a login and a password to this console and Zabbix has support for this. In our item, there is a box where we can add a login and a password.
If you run into issues and you probably will, the best thing to do is to go and check the jmx log
files under:
/var/log/zabbix_java_gateway.log