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
include double quotes in command line definition
Re: include double quotes in command line definition
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]
[[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]
-
npolovenko
- Support Tech
- Posts: 3457
- Joined: Mon May 15, 2017 5:00 pm
Re: include double quotes in command line definition
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.
Can you actually switch to nagios user in a console: And then run the command that worked for you before:
If it doesn't work from the command line under Nagios user then it's probably some permission problem.
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]Code: Select all
su - nagiosCode: 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 60000As of May 25th, 2018, all communications with Nagios Enterprises and its employees are covered under our new Privacy Policy.
Re: include double quotes in command line definition
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
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
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!!
-
npolovenko
- Support Tech
- Posts: 3457
- Joined: Mon May 15, 2017 5:00 pm
Re: include double quotes in command line definition
@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.
As of May 25th, 2018, all communications with Nagios Enterprises and its employees are covered under our new Privacy Policy.