JMX checks

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.

Getting ready

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.

How to do it…

  1. First thing to do on our Zabbix server is to install the Java gateway. This can be done with the following command:
    yum install zabbix-java-gateway
    
  2. Make the Java gateway start up automatic next reboot:
    chkconfig zabbix-java-gateway on
    

    For RHEL 7:

    systemctl enable zabbix-java-gateway
    
  3. Start the Java gateway:
    service start zabbix-java-gateway
    

    For RHEL 7:

    systemctl start zabbix-java-gateway 
    
  4. In the zabbix_server.conf file, change the following options:
    Java gateway = 127.0.0.1
    Java Gateway Port = 10052
    Start Java pollers = 2
  5. Don't forget to restart your zabbix-server:
    service zabbix-server restart
    

    For RHEL 7:

    systemctl restart zabbix-server
    
  6. There is a zabbix-java-gateway.conf file as well, where you can specify the same parameters to update this file.
  7. Now you need to enable the JMX interface on the application on your host. This you have to do per application as the JMX interface usually comes disabled. Example:
    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
  8. Another solution could be to add this to the configuration file of your application.
  9. The next step is to create the JMX interface on our host in Zabbix.
    How to do it…
  10. As the last step, create your item on the host and give it a proper Name.
  11. The Type this time will be JMX agent.
  12. Add the JMX item you would like to be monitored in the Key field.
  13. Select the proper Host interfaces.
    How to do it…
  14. Don't forget to open the proper ports in your firewall.
  15. Go check the latest data page for your data.

There's more...

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

Tip

Only one Java gateway can be installed on the Zabbix server or alternatively you could install one per proxy.

When you compile it may be a good idea to add some prefix for the location, as the gateway comes with a whole tree of files and directories. Example:

--prefix=/opt/zabbix_java_gateway
..................Content has been hidden....................

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