Nagios check_jmx plugin + jconsole usage

2018, Jul 28

check_jmx plugin is a powerful tool for monitoring the JVM. Examples of using this plugin are limited on the Internet, so you can use jconsole tool to see what to monitor.

Before using jconsole, you need to create a SSH socks tunnel proxy (e.g. 7777).

You can find jconsole tool in Java\jdk1.8.0_171\bin directory (example of path). Open a cmd in this directory and run this:

.\jconsole.exe -J-DsocksProxyHost=localhost -J-DsocksProxyPort=7777 service:jmx:rmi:///jndi/rmi://localhost:9003/jmxrmi -J-DsocksNonProxyHosts=

(9003 is the default port for JMX in Hybris eCommerce)

This will open a dashboard of jconsole where you can see a lot of real time good information about JVM.

As an example of using check_jmx:

  • Open jconsole. Select MBeans, java.lang -> Threading.
  • You can see here the ObjectName: java.lang:type=Threading
  • Select Attributes. Now you can see ThreadCount attribute.

This can translate to check_jmx with this:

/usr/local/nagios/libexec/check_jmx -U service:jmx:rmi:///jndi/rmi://localhost:9003/jmxrmi -O java.lang:type=Threading -A ThreadCount -K "" -w 200 -c 250