Page 1 of 1

include double quotes in command line definition

Posted: Thu Feb 01, 2018 11:27 am
by jh129666
I have the below command line definition in nagios for a check command, and I want the $ARG2$ variable to have double quotes around the value when the command is executed, so it would like name="value". I've tried "$ARG2$" and \"$ARG2$\" but those didn't work.

$USER1$/check_jmx -U service:jmx:rmi:///jndi/rmi://$HOSTADDRESS$:$ARG1$/jmxrmi -O org.apache.camel:context=camel-1,type=routes,name=$ARG2$ $ARG3$

If I run this from the command line on the nagios server it works, but I'm not sure what needs to be done for name=$ARG2$ so the value of $ARG2$ will include double quotes.

/usr/local/nagios/libexec/check_jmx -U service:jmx:rmi:///jndi/rmi://xxxms001:8363/jmxrmi -O org.apache.camel:context=camel-1,type=routes,name='"fileCleanupTimer"' -A MaxProcessingTime -w 59000 -c 60000

Re: include double quotes in command line definition

Posted: Thu Feb 01, 2018 11:47 am
by jh129666
when I use name="$ARG2$" in the command definition and then do the "Run Check Command" in the UI, it looks like the value of $ARG2$ has double quotes ("fileCleanupTimer") but then the command fails saying it can't find the object name. In that message there are no double quotes around fileCleanupTimer, so it looks like they were stripped for some reason.

[[email protected] ~]$ /usr/local/nagios/libexec/check_jmx -U service:jmx:rmi:///jndi/rmi://slmms001:8497/jmxrmi -O org.apache.camel:context=camel-1,type=routes,name="fileCleanupTimer" -A MaxProcessingTime -w 59000 -c 60000
JMX CRITICAL - objectName not found [org.apache.camel:context=camel-1,type=routes,name=fileCleanupTimer]

Re: include double quotes in command line definition

Posted: Thu Feb 01, 2018 2:01 pm
by npolovenko
Hello, @jh129666. When you click on "Run the command" in core configurations manager it runs it as the apache user, which doesn't always interpret macros correctly. I'd use a "$ARG2$" (with double quotes in the command). Then actually save the config, click on Apply configuration and see if it works in Service Overview in the web interface.

Code: Select all

[[email protected] ~]$ /usr/local/nagios/libexec/check_jmx -U service:jmx:rmi:///jndi/rmi://slmms001:8497/jmxrmi -O org.apache.camel:context=camel-1,type=routes,name="fileCleanupTimer" -A MaxProcessingTime -w 59000 -c 60000
JMX CRITICAL - objectName not found [org.apache.camel:context=camel-1,type=routes,name=fileCleanupTimer]
Can you actually switch to nagios user in a console:

Code: Select all

su - nagios
And then run the command that worked for you before:

Code: Select all

/usr/local/nagios/libexec/check_jmx -U service:jmx:rmi:///jndi/rmi://xxxms001:8363/jmxrmi -O org.apache.camel:context=camel-1,type=routes,name='"fileCleanupTimer"' -A MaxProcessingTime -w 59000 -c 60000
If it doesn't work from the command line under Nagios user then it's probably some permission problem.

Re: include double quotes in command line definition

Posted: Thu Feb 01, 2018 3:23 pm
by jh129666
When using "$ARG2$" it does not work in service status detail in the web interface. It fails because the value of name= is fileCleanupTimer instead of "fileCleanupTimer".

Any other suggestions for resolving this?

JMX CRITICAL - objectName not found [org.apache.camel:context=camel-1,type=routes,name=fileCleanupTimer]


The command that worked before was run as the nagios user on the nagios server.

/usr/local/nagios/libexec/check_jmx -U service:jmx:rmi:///jndi/rmi://xxxms001:8363/jmxrmi -O org.apache.camel:context=camel-1,type=routes,name='"fileCleanupTimer"' -A MaxProcessingTime -w 59000 -c 60000

Re: include double quotes in command line definition

Posted: Thu Feb 01, 2018 3:45 pm
by jh129666
After trial and error, I was able to make it work by using $ARG2$ in the command definition and then passing the value between a set of single then double quotes, so '"value"'. This can be closed. Thanks!!

Re: include double quotes in command line definition

Posted: Thu Feb 01, 2018 3:54 pm
by npolovenko
@jh129666, Thanks for sharing the solution with us! I'm sure someone would need it in the future. I'll lock this thread as resolved.