check_jmx plugin works on client but not on nagios server

This support forum board is for support questions relating to Nagios XI, our flagship commercial network monitoring solution.
jh129666
Posts: 98
Joined: Mon Feb 11, 2013 3:45 pm

check_jmx plugin works on client but not on nagios server

Post by jh129666 »

The check_jmx command works on the client, but when I run it on the nagios server it doesn't work. I'm thinking it's because the double quotes around activemq (name='"activemq"') need to be escaped but I'm not sure, and none of the escaping I've tried so far has worked.

Any suggestions?

./check_jmx -U service:jmx:rmi:///jndi/rmi://xxxxxxxx:1234/jmxrmi -O org.apache.camel:context=camel-1,type=components,name='"activemq"' -A State
JMX OK - State=Started

/usr/local/nagios/libexec/check_nrpe -H xxxxxxxx -c check_jmx -a '-U service:jmx:rmi:///jndi/rmi://xxxxxxxx:1234/jmxrmi -O org.apache.camel:context=camel-1,type=components,name='"activemq"' -A State'
JMX CRITICAL - org.apache.camel:context=camel-1,type=components,name=activemq
npolovenko
Support Tech
Posts: 3457
Joined: Mon May 15, 2017 5:00 pm

Re: check_jmx plugin works on client but not on nagios serve

Post by npolovenko »

Hello, @jh129666 . You said this plugin doesn't work on the client's server. Is that only using NRPE? Can you run this plugin locally on the client's server without using nrpe? Please post the output. Are there any other nrpe checks on that remote server that are actually working with Nagios server?
Also please upload the command definition from the nrpe.cfg file on the remote server.
As of May 25th, 2018, all communications with Nagios Enterprises and its employees are covered under our new Privacy Policy.
jh129666
Posts: 98
Joined: Mon Feb 11, 2013 3:45 pm

Re: check_jmx plugin works on client but not on nagios serve

Post by jh129666 »

The plugin works on the client server when run locally (see below). It doesn't work when running from the nagios server using check_nrpe.

./check_jmx -U service:jmx:rmi:///jndi/rmi://xxxxxxxx:1234/jmxrmi -O org.apache.camel:context=camel-1,type=components,name='"activemq"' -A State
JMX OK - State=Started

Here's the command definition from nrpe.cfg.


command[check_jmx]=/usr/local/nagios/plugins/check_jmx $ARG1$
npolovenko
Support Tech
Posts: 3457
Joined: Mon May 15, 2017 5:00 pm

Re: check_jmx plugin works on client but not on nagios serve

Post by npolovenko »

@jh129666, I think you should try to delete both single and double quotes around activemql.

Code: Select all

/usr/local/nagios/libexec/check_nrpe -H xxxxxxxx -c check_jmx -a '-U service:jmx:rmi:///jndi/rmi://xxxxxxxx:1234/jmxrmi -O org.apache.camel:context=camel-1,type=components,name=activemq -A State'
Option number 2 would be to hardcode the whole command in nrpe.cfg. So instead of:

Code: Select all

command[check_jmx]=/usr/local/nagios/plugins/check_jmx $ARG1$
You'd change it to:

Code: Select all

command[check_jmx]=/usr/local/nagios/plugins/check_jmx -U service:jmx:rmi:///jndi/rmi://xxxxxxxx:1234/jmxrmi -O org.apache.camel:context=camel-1,type=components,name='"activemq"' -A State
Save that, then restart NRPE with service nrpe restart OR service xinetd restart depending on your agent.

After that force the check from Nagios server.
As of May 25th, 2018, all communications with Nagios Enterprises and its employees are covered under our new Privacy Policy.
jh129666
Posts: 98
Joined: Mon Feb 11, 2013 3:45 pm

Re: check_jmx plugin works on client but not on nagios serve

Post by jh129666 »

removing the single and double quotes from activemq doesn't work as the actual value I want to check in the MBean tree is "activemq" and not activemq.

I'll hard code the command and see if that works.

/usr/local/nagios/libexec/check_nrpe -H xxxxxxx -c check_jmx -a '-U service:jmx:rmi:///jndi/rmi://xxxxxxxx:1234/jmxrmi -O org.apache.camel:context=camel-1,type=components,name=activemq -A State'
JMX CRITICAL - org.apache.camel:context=camel-1,type=components,name=activemq
jh129666
Posts: 98
Joined: Mon Feb 11, 2013 3:45 pm

Re: check_jmx plugin works on client but not on nagios serve

Post by jh129666 »

hard coding the command works using check_nrpe from the nagios server, but I want to get it working without hard coding it. How do the double quotes around activemq need to be escaped so the value of name= is "activemq"?

/usr/local/nagios/libexec/check_nrpe -H xxxxxxxx -c check_jmx
JMX OK - State=Started
npolovenko
Support Tech
Posts: 3457
Joined: Mon May 15, 2017 5:00 pm

Re: check_jmx plugin works on client but not on nagios serve

Post by npolovenko »

@jh129666, I think you should be able to just have double quotes around activemq. I think the main problem was that you had single quotes on top of the double quotes. And because your command starts with a single quote as well, everything after the next single quote occurrence would get cut off. Change the command in npre.cfg to what it was before and try this:

Code: Select all

/usr/local/nagios/libexec/check_nrpe -H xxxxxxx -c check_jmx -a '-U service:jmx:rmi:///jndi/rmi://xxxxxxxx:1234/jmxrmi -O org.apache.camel:context=camel-1,type=components,name="activemq" -A State'
As of May 25th, 2018, all communications with Nagios Enterprises and its employees are covered under our new Privacy Policy.
jh129666
Posts: 98
Joined: Mon Feb 11, 2013 3:45 pm

Re: check_jmx plugin works on client but not on nagios serve

Post by jh129666 »

I tried double quotes around activemq and that doesn't work. If you look at the response below you can see that name=activemq, so even though I put double quotes around activemq in the command, it looks like name=activemq is what's being used.

/usr/local/nagios/libexec/check_nrpe -H xxxxxxxx -c check_jmx -a '-U service:jmx:rmi:///jndi/rmi://xxxxxxxx:1234/jmxrmi -O org.apache.camel:context=camel-1,type=components,name="activemq" -A State'
JMX CRITICAL - org.apache.camel:context=camel-1,type=components,name=activemq
User avatar
lmiltchev
Bugs find me
Posts: 13589
Joined: Mon May 23, 2011 12:15 pm

Re: check_jmx plugin works on client but not on nagios serve

Post by lmiltchev »

Try changing the command on the remote box by wrapping the $ARG1$ in double quotes:

Code: Select all

command[check_jmx]=/usr/local/nagios/plugins/check_jmx "$ARG1$"
Save, exit and restart nrpe (or xinetd).

Test your command from the Nagios XI box:

Code: Select all

/usr/local/nagios/libexec/check_nrpe -H <client ip> -c check_jmx -a '-U service:jmx:rmi:///jndi/rmi://xxxxxxxx:1234/jmxrmi -O org.apache.camel:context=camel-1,type=components,name='"activemq"' -A State'
Did this help?
Be sure to check out our Knowledgebase for helpful articles and solutions!
jh129666
Posts: 98
Joined: Mon Feb 11, 2013 3:45 pm

Re: check_jmx plugin works on client but not on nagios serve

Post by jh129666 »

No, that didn't work either.

command[check_jmx]=/usr/local/nagios/plugins/check_jmx "$ARG1$"

/usr/local/nagios/libexec/check_nrpe -H host -c check_jmx -a '-U service:jmx:rmi:///jndi/rmi://host:port/jmxrmi -O org.apache.camel:context=camel-1,type=components,name='"activemq"' -A State'
JMX UNKNOWN Required options not specified Usage: check_jmx -help
Locked