Page 1 of 1

NRPE: Unable to read output - check_jmx

Posted: Tue Mar 20, 2018 1:26 pm
by ntobars
HI Team,

I'm trying to monitor tomcat using the check_jmx plugin from the following URL:

https://library.nagios.com/library/prod ... nagios-xi/

I follow each step correctly and I currently have problems when I run the command from the NagiosXI server

Error
[root@nagiosXI linux]# /usr/local/nagios/libexec/check_nrpe -H 192.168.1.2 -c check_jmx -a '-U service:jmx:rmi:///jndi/rmi://127.0.0.1:9696/jmxrmi -O java.lang:type=Memory -A HeapMemoryUsage -K used -I HeapMemoryUsage -J used -vvvv -w 4248302272 -c 5498760192'
NRPE: Unable to read output

NRPE Test
[root@nagiosXI linux]# /usr/local/nagios/libexec/check_nrpe -H 192.168.1.2
NRPE v3.2.1

Client configuration

[root@tomcat libexec]# grep check_jmx /usr/local/nagios/etc/nrpe.cfg
command[check_jmx]=/usr/local/nagios/libexec/check_jmx $ARG1$

root user
[root@tomcat libexec]# ./check_jmx -U service:jmx:rmi:///jndi/rmi://localhost:9696/jmxrmi -O java.lang:type=Memory -A HeapMemoryUsage -K used -I HeapMemoryUsage -J used -vvvv -w 4248302272 -c 5498760192
JMX OK - HeapMemoryUsage.used=2131803240 | HeapMemoryUsage.used=2131803240,committed=3617685504;init=1073741824;max=12850036736;used=2131803240

nagios user
[nagios@tomcat libexec]$ echo $JAVA_HOME
/app/jdk1.7.0_67
[nagios@tomcat libexec]$ ./check_jmx -U service:jmx:rmi:///jndi/rmi://localhost:9696/jmxrmi -O java.lang:type=Memory -A HeapMemoryUsage -K used -I HeapMemoryUsage -J used -vvvv -w 4248302272 -c 5498760192
JMX OK - HeapMemoryUsage.used=2016888832 | HeapMemoryUsage.used=2016888832,committed=3617685504;init=1073741824;max=12850036736;used=2016888832

Re: NRPE: Unable to read output - check_jmx

Posted: Tue Mar 20, 2018 9:20 pm
by mcapra
Have you tried hard-coding this bit in your NRPE 'check_jmx' command definition:

Code: Select all

-U service:jmx:rmi:///jndi/rmi://127.0.0.1:9696/jmxrmi -O java.lang:type=Memory -A HeapMemoryUsage -K used -I HeapMemoryUsage -J used -vvvv -w 4248302272 -c 5498760192
Rather than passing it via check_nrpe? That will rule out an awful lot of potential escaping issues, though I don't suspect there are any.

It's worth mentioning that, if you're relying on Bash to resolve the java command on behalf of the nagios user, this won't necessarily work when NRPE executes a given command since NRPE doesn't do so through Bash. You could modify check_jmx to include the full path to the java binary to rule out potential environmental issues. Something like this:

Code: Select all

#!/bin/sh
#
# Nagios plugin to monitor Java JMX (http://java.sun.com/jmx)attributes.
#
RDIR=`dirname $0`
/path/to/jdk/bin/java  -jar $RDIR/jmxquery.jar "$@"

Re: NRPE: Unable to read output - check_jmx

Posted: Wed Mar 21, 2018 3:25 pm
by kyang
Thanks for the help @mcapra!