Re: JMX SSL monitoring
Posted: Mon Dec 12, 2016 2:03 pm
I was finally able to get this working for my Tomcat 7 machine. I'll attach a copy of the modified jmxquery.jar I was using which contains some extra bits that make SSL work against my test machine. Be aware that the classpath is different on the jmxquery attached to this post (i'm using JMXQuery instead of org.nagios.JMXQuery).
I generated the keystore on the Tomcat machine like so:
Java system properties for Tomcat:
Properties of note:
Then I moved the keystore to the Nagios XI machine (placed it in /usr/local/nagios/libexec/keystore.jks) as a lazy way of testing and used it as the truststore in my system properties.
Regular output from the Nagios XI machine using a modified jmxquery:
And here's the output with extra debug info confirming the important SSL bits are functional (it's really long so I put it in a pastebin):
http://pastebin.com/kRrh0Njq
I also made the following changes to the check_jmx wrapper script that Nagios XI leverages:
And was able to use that just as well as the jar:
I generated the keystore on the Tomcat machine like so:
Code: Select all
keytool -genkeypair -alias tomcat -keyalg RSA -keystore keystore.jks -dname cn=test,ou=test,dc=example,dc=com
Code: Select all
[root@localhost tomcat]# ps aux | grep java
tomcat 7977 12.5 4.9 3998064 191748 ? Ssl 12:51 0:18 /usr/lib/jvm/jre/bin/java -Dcom.sun.management.jmxremote -Djava.rmi.server.hostname=192.168.67.96 -Dcom.sun.management.jmxremote.port=9010 -Dcom.sun.management.jmxremote.registry.ssl=true -Dcom.sun.management.jmxremote.ssl=true -Dcom.sun.management.jmxremote.ssl.need.client.auth=false -Djavax.net.ssl.keyStorePassword=welcome -Djavax.net.ssl.keyStore=/etc/tomcat/keystore.jks -Dcom.sun.management.jmxremote.local.only=false -Dcom.sun.management.jmxremote.authenticate=false -Djava.security.egd=file:/dev/./urandom -Djava.awt.headless=true -Xmx512m -XX:MaxPermSize=256m -XX:+UseConcMarkSweepGC -classpath /usr/share/tomcat/bin/bootstrap.jar:/usr/share/tomcat/bin/tomcat-juli.jar:/usr/share/java/commons-daemon.jar -Dcatalina.base=/usr/share/tomcat -Dcatalina.home=/usr/share/tomcat -Djava.endorsed.dirs= -Djava.io.tmpdir=/var/cache/tomcat/temp -Djava.util.logging.config.file=/usr/share/tomcat/conf/logging.properties -Djava.util.logging.manager=org.apache.juli.ClassLoaderLogManager org.apache.catalina.startup.Bootstrap start
Code: Select all
-Dcom.sun.management.jmxremote.registry.ssl=true
-Dcom.sun.management.jmxremote.ssl=true
-Dcom.sun.management.jmxremote.ssl.need.client.auth=false
-Djavax.net.ssl.keyStorePassword=welcome
-Djavax.net.ssl.keyStore=/etc/tomcat/keystore.jks
-Dcom.sun.management.jmxremote.local.only=false
-Dcom.sun.management.jmxremote.authenticate=false
Regular output from the Nagios XI machine using a modified jmxquery:
Code: Select all
[root@localhost libexec]# java -Djavax.net.ssl.trustStore=/usr/local/nagios/libexec/keystore.jks -Djavax.net.ssl.trustStorePassword=welcome -cp jmxquery.jar JMXQuery -U service:jmx:rmi:///jndi/rmi://192.168.67.96:9010/jmxrmi -O java.lang:type=Memory -A HeapMemoryUsage -K used -I HeapMemoryUsage -J used -vvvv
JMX OK HeapMemoryUsage.used=21731024{committed=60817408;init=62914560;max=518979584;used=21731024}|used=21731024;0;0
http://pastebin.com/kRrh0Njq
I also made the following changes to the check_jmx wrapper script that Nagios XI leverages:
Code: Select all
#!/bin/sh
#
# Nagios plugin to monitor Java JMX (http://java.sun.com/jmx)attributes.
#
RDIR=`dirname $0`
java -Djavax.net.ssl.trustStore=/usr/local/nagios/libexec/keystore.jks -Djavax.net.ssl.trustStorePassword=welcome -cp $RDIR/jmxquery.jar JMXQuery $@
Code: Select all
[root@localhost libexec]# ./check_jmx -U service:jmx:rmi:///jndi/rmi://192.168.67.96:9010/jmxrmi -O java.lang:type=Memory -A HeapMemoryUsage -K used -I HeapMemoryUsage -J used -vvvv
JMX OK HeapMemoryUsage.used=26155280{committed=60817408;init=62914560;max=518979584;used=26155280}|used=26155280;0;0