Search Exchange

Search All Sites

Nagios Live Webinars

Let our experts show you how Nagios can help your organization.

Contact Us

Phone: 1-888-NAGIOS-1
Email: sales@nagios.com

Login

Remember Me

Directory Tree

check_jmx

Rating
21 votes
Favoured:
3
Hits
240234
Files:
FileDescription
check_jmx.tgzcheck_jmx version 0.3
Nagios CSP

Meet The New Nagios Core Services Platform

Built on over 25 years of monitoring experience, the Nagios Core Services Platform provides insightful monitoring dashboards, time-saving monitoring wizards, and unmatched ease of use. Use it for free indefinitely.

Monitoring Made Magically Better

  • Nagios Core on Overdrive
  • Powerful Monitoring Dashboards
  • Time-Saving Configuration Wizards
  • Open Source Powered Monitoring On Steroids
  • And So Much More!
Java JMX Nagios Plugin
Updated version of the original check_jmx plugin fixed to support values larger than an Integer could provide. There are no other changes.

Example usage (where $hostname and $port are the hostname and port to check):
./check_jmx -U service:jmx:rmi:///jndi/rmi://$hostname:$port/jmxrmi -O java.lang:type=Memory -A HeapMemoryUsage -K used -I HeapMemoryUsage -J used -vvvv -w 4248302272 -c 5498760192

Original Description:
Java JMX Nagios plugin enables you to monitor JMX attributes in Nagios.
As soon as JMX embedded in Java 5, any Java process may expose parameters to be monitored using JMX interface,
look http://java.sun.com/j2se/1.5.0/docs/guide/management/agent.html and http://java.sun.com/jmx for details
In Java version <5 it is still possible to expose JMX interface using third party libraries

To see what can be monitored by JMX, run /bin/jconsole.exe and connect to
the host/port you setup in your Java process.

Some examples are:
* standard Java JMX implementation exposes memory, threads, OS, garbage collector parameters
* Tomcat exposes multiple parameters - requests, processing time, threads, etc..
* spring framework allows to expose Java beans parameters to JMX
* your application may expose any attributes for JMX by declaration or explicitly.
* can monitor localhost or remote processes

Includes Munin plugin for JMX as well.
Reviews (19)
Graph should shows in GBs not in Bytes. It is more easy to read the Graph. Remember not everyone is a technical person.
@InscrutableDude

>I will mention that the doc I found that shows how to install it is out of date.

Can you elaborate on the statement above?

Thanks!
This plugin is great. I will mention that the doc I found that shows how to install it is out of date. ( https://assets.nagios.com/downloads/nagiosxi/docs/Monitoring-JMX-with-Nagios-XI.pdf?_ga=2.175104545.226851872.1496153715-1369431108.1490715442 )

But, once running, it gives you pretty much anything you could need. We've gone from kind of flying blind, to being instantly aware of any potential issues with our many java instances. Thanks to the dev!
May I know, how to trust a SSl certificate for jmx monitoring in nagios server
byelocholero, June 9, 2016
@pabloluna
Make this local, and SLL the nrpe, my only thought pabloluna.
bypabloluna, May 31, 2016
This is a wonderfull plugin and I have used for three years in order to check JVM parameters. I have a recent question. We can encrypt JMX traffic like this: https://db.apache.org/derby/docs/10.10/adminguide/radminjmxenablepwdssl.html from the application server.

But I dont find any mode to make a client connection with check_jmk plugin using SSL. Is this possible? Thank you.
I tried this: "./check_jmx -U service:jmx:rmi:///jndi/rmi://127.0.0.1:6000/jmxrmi -O java.lang:type=MemoryPool,name=PS Eden Space -A Usage -I Usage -K used -J used -vvvv -w 4248302272 -c 5498760192" with multiple combinations of quotes and single quotes, and it doesn't work, any advices?
byraza, February 29, 2016
I received the following error when tried check_jmx from this link https://github.com/atamariya/nagios-check-jmx .

[root@sc-nagiosxi plugin]# ./check_jmx -help
Exception in thread "main" java.lang.UnsupportedClassVersionError: org/nagios/JMXQuery : Unsupported major.minor version 52.0
at java.lang.ClassLoader.defineClass1(Native Method)
at java.lang.ClassLoader.defineClass(Unknown Source)
at java.security.SecureClassLoader.defineClass(Unknown Source)
at java.net.URLClassLoader.defineClass(Unknown Source)
at java.net.URLClassLoader.access$100(Unknown Source)
at java.net.URLClassLoader$1.run(Unknown Source)
at java.net.URLClassLoader$1.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at sun.launcher.LauncherHelper.checkAndLoadMain(Unknown Source)
[root@sc-nagiosxi plugin]# java -version
java version "1.7.0_67"
Java(TM) SE Runtime Environment (build 1.7.0_67-b01)
Java HotSpot(TM) 64-Bit Server VM (build 24.65-b04, mixed mode)



The plugin link here for download (check_jmx.tgz version 3) works but doesn't show any graph or trend data.
byatamariya, December 5, 2015
I've added perfdata output for graphing. The updated code is available at https://github.com/atamariya/nagios-check-jmx
MessageCount does not report the proper messages in a topic.

Synopsis:

MessageCount parameter returns 0. Then....Start hermes and connect to the same topic. If Heremes shows 6 messages in the topic, now run check_jmx and it will show 6 messages.

Now, connect Hermes on another machine (This is now the second instance of hermes) and connect it to the same topic. You now have two versions of heremes dispaying 6 messages. Now run check_jmx, and it will say that there are 12 messages.

Close both instances of hermes, and run check_jmx and it will now show 0 messages. This is crazy.

Took a long time to figure this out.
I had to declare a single command for each attribute i wanted to monitor. But i have 210 jmx checks to monitor.
So, after having tests about how to template jmx checks, finally syabru nagios plugin made it.

What i obtained with this "check_jmx" plugin with this setup :
- nrpe host client :
command[test_check_jmx]=/usr/local/nagios/libexec/check_jmx -U service:jmx:rmi:///jndi/rmi://localhost:$ARG1$/jmxrmi -O org.apache.camel:context=$ARG2$/mainContext,type=$ARG3$,name=\"$ARG4$\" -A $ARG5$ -w $ARG6$ -c $ARG7$
- nagios nrpe server :
./check_nrpe -H 10.20.0.11 -u -c test_check_jmx_dcd_failures -a 10010 satais-esb1 processors threadProcessor FailuresHandled 1 10
JMX UNKNOWN java.lang.NumberFormatException: For input string: "10satais-esb1/mainContext,type=processors,name="threadProcessor"" connecting to org.apache.camel:context=satais-esb1/mainContext,type=processors,name="threadProcessor" by URL service:jmx:rmi:///jndi/rmi://localhost:10010/jmxrmiorg.nagios.ParseError: java.lang.NumberFormatException: For input string: "10satais-esb1/mainContext,type=processors,name="threadProcessor"" at org.nagios.JMXQuery.parse(JMXQuery.java:250) at org.nagios.JMXQuery.main(JMXQuery.java:74) Caused by: java.lang.NumberFormatException: For input string: "10satais-esb1/mainContext,type=processors,name="threadProcessor"" at java.lang.NumberFormatException.forInputString(NumberFormatException.java:65) at java.lang.Long.parseLong(Long.java:438) at java.lang.Long.parseLong(Long.java:478) at org.nagios.JMXQuery.parse(JMXQuery.java:242) ... 1 more Usage: check_jmx -help

- And with the syabru nagios jmx plugin :
./check_nrpe -H 10.20.0.11 -u -c test_check_jmx_dcd_failures -a 10010 satais-esb1 processors threadProcessor FailuresHandled 1 10
JMX OK - FailuresHandled = 0 | 'FailuresHandled'=0;1;10;;
I really like this plugin. It works well once you get the performance data bit added.

However, I'm hitting a problem which isn't necessarily an issue with the plugin but I'm putting it out there because I can't find a resolution at the moment.

I can be monitoring away happily for my application running in Jboss AS4 and checks are working fine and I'm getting performance data graphs etc. Then I restart my application and my service checks stop working, reporting that the checks that were working perfectly well previously now can't find any registered MBeans. The error is something along the lines of InstanceNotFound and Mbean not registered.
The weird thing is, if I fire up jconsole and go to the MBeans tab, all the mbeans are there and soon after my check_jmx service checks start working! But they won't work until I fire up jconsole and access the MBeans tab.
Que?
bytoimtoimtoim, November 27, 2012
1 of 1 people found this review helpful
If you need perf data for your nagios then you could use this script. I have combined other things mentioned in past reviews and added little sed magic to format perf data in correct way.

Atleast for "check_jmx -U service:jmx:rmi:///jndi/rmi://localhost:8060/jmxrmi -O java.lang:type=Memory -A HeapMemoryUsage -K used -I HeapMemoryUsage -J used -vvvv -w 4248302272 -c 5498760192"

output seems to be ok
"JMX OK HeapMemoryUsage.used=70437104{committed=202899456;init=209715200;max=608174080;used=70437104} | committed=202899456; init=209715200; max=608174080; used=70437104;"


#!/bin/sh
JAVA_CMD=`which java`
if [ -z $JAVA_CMD ]
then
if [ -x $JAVA_HOME/bin/java ]
then
JAVA_CMD=$JAVA_HOME/bin/java
else
echo JMX CRITICAL - java not found.
exit 2
fi
fi

RDIR=`dirname $0`
OUTPUT=$($JAVA_CMD -cp $RDIR/jmxquery.jar org.nagios.JMXQuery $@)
EXIT_STATUS=$?
STATUS=`echo $OUTPUT`
VALUE=$(echo $OUTPUT | sed 's/.*{\(.*\)}.*/\1;/' | sed 's/;/; /g')
echo "$STATUS | $VALUE"

exit $EXIT_STATUS
byjohntdyer, October 10, 2012
I am having some issue executing an operation via JMX

./check_jmx -U service:jmx:rmi:///jndi/rmi://127.0.0.1:47520/rmi -O "java.lang:type=Threading" -o findDeadlockedThreads

Anyone have any idea how I can programmatically monitor this operation to detect a threadlock ?
byrayzeller, May 3, 2012
This is an old version. If you want this to work with nrpe, you must have the following: {noformat}

#!/bin/sh
#
# Nagios JMX plugin.
#

JAVA_CMD=`which java`

if [ -z $JAVA_CMD ]
then

if [ -x $JAVA_HOME/bin/java ]
then
JAVA_CMD=$JAVA_HOME/bin/java
else
echo JMX CRITICAL - java not found.
exit 2
fi

fi

DIR=`dirname $0`
$JAVA_CMD -jar $DIR/check_jmx.jar "$@"
{noformat}
as your check_jmx. Otherwise nrpe will not be able to find java.
The problem is most likely permissions. To check what was going on, I executed the script as the nagios user on the remote
machine:

bash /usr/lib/nagios/plugins/contrib/check_jmx -U service:jmx:rmi:///jndi/rmi://localhost:8997/jmxrmi -O java.lang:type=Memory -A HeapMemoryUsage -K used -I HeapMemoryUsage -J used -vvvv -w 10000000 -c 100000000
/usr/lib/nagios/plugins/contrib
Exception in thread "main" java.lang.NoClassDefFoundError: org/nagios/JMXQuery
Caused by: java.lang.ClassNotFoundException: org.nagios.JMXQuery
at java.net.URLClassLoader$1.run(URLClassLoader.java:202)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:190)
at java.lang.ClassLoader.loadClass(ClassLoader.java:307)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301)
at java.lang.ClassLoader.loadClass(ClassLoader.java:248)

Was the output. the issue was the permissions of the jmxquery.jar file:

root@dvl_app-1:/usr/lib/nagios/plugins/contrib# ls -al
total 56
drwxrwxr-x 2 root root 4096 2011-09-19 10:47 .
drwxrwxr-x 3 root root 4096 2011-09-16 17:04 ..
-r-xr-xr-x 1 root root 28423 2011-09-16 17:04 check_diskio
-rwxr-xr-x 1 nagios nagios 177 2011-09-19 10:52 check_jmx
-rwx------ 1 root root 13225 2011-09-19 09:55 jmxquery.jar

Was what I had. To fix I ran:
chown nagios.nagios /usr/lib/nagios/plugins/contrib/jmxquery.jar

and from my nagios monitoring machine I ran:

/usr/local/nagios/libexec/check_nrpe -H 184.73.5.19 -c check_jmx
JMX CRITICAL HeapMemoryUsage.used=233372176{committed=266797056;init=0;max=266797056;used=233372176}
The current check_jmx shell script won't return information to the performance gathering subsystem in Nagios. Add-ons like PNP4nagios aren't able to pick up the returned values without the proper output.

I offer this little hack...


RDIR=`dirname $0`
OUTPUT=`java -cp $RDIR/jmxquery.jar org.nagios.JMXQuery $@`
EXIT_STATUS=$?
STATUS=`echo $OUTPUT`
VALUE=`echo $OUTPUT | awk '{print $NF}'`
echo "$STATUS | $VALUE"

exit $EXIT_STATUS
byrremingt, November 15, 2010
I'm working on using check_jmx over NRPE. I'm sure the issue has something to do with the limits on data passed between check_nrpe and the remote nrpe daemon. I use NRPE with the perl-based check_multi plug-in and have to increase the data buffer sizes in the C code itself. I'll write again if I have success in getting check_jmx working with NRPE...
Looks like a good start, but it is missing some informations. There is no way I can make it work with NRPE, even if I run it ok directly in my shell account :

[nagios@myserver ~]$ /usr/local/nagios/libexec/check_jmx -U service:jmx:rmi:///jndi/rmi://localhost:8999/jmxrmi -O java.lang:type=Memory -A HeapMemoryUsage -K used -I HeapMemoryUsage -J used -vvvv -w 800000000 -c 1500000000
JMX WARNING HeapMemoryUsage.used=842512960{committed=1042808832;init=1073741824;max=1042808832;used=842512960}


I checked a lot of things, but I am still stuck with the following message :

[nagios@myserver ~]$ /usr/local/nagios/libexec/check_nrpe -H localhost -c check_jmx
NRPE: Unable to read output