Using Argument with Space and Double Quote in check_nrpe

Support forum for Nagios Core, Nagios Plugins, NCPA, NRPE, NSCA, NDOUtils and more. Engage with the community of users including those using the open source solutions.
Locked
phan
Posts: 3
Joined: Tue Nov 22, 2011 5:57 am

Using Argument with Space and Double Quote in check_nrpe

Post by phan »

Hello experts,

I would like to know if there is any way to submit a string of argument that contains space and double quotation to check_nrpe. So for example, my line would be something like:

check_nrpe -H 192.168.0.1 -c nagios_mychecker -a "--userName phan --mode check_error --errorCode "AA 001" --warnThreshold 70 --critThreshold 75"

The double quote and the space are literally part of the strings I am looking for. I could do without the double quote, but omitting the space would cause the script to return too many false findings.
User avatar
jsmurphy
Posts: 989
Joined: Wed Aug 18, 2010 9:46 pm

Re: Using Argument with Space and Double Quote in check_nrpe

Post by jsmurphy »

I'm not 100% sure but something along the lines of "\"AA 001\"" may work... escaping the quotes so they become literal, although if you just want the space; what you have already done should work.
phan
Posts: 3
Joined: Tue Nov 22, 2011 5:57 am

Re: Using Argument with Space and Double Quote in check_nrpe

Post by phan »

Hi,

I did try the escape backslash, but that did not work unfortunately.

What I had would work if I just execute the script by itself, but as soon as I put the parameters in the -a switch of check_nrpe, it doesn't work.
User avatar
jsmurphy
Posts: 989
Joined: Wed Aug 18, 2010 9:46 pm

Re: Using Argument with Space and Double Quote in check_nrpe

Post by jsmurphy »

Oh I see I missed the first set of quotes... does single quoting the inner set work? I.e. 'AA 001' instead
phan
Posts: 3
Joined: Tue Nov 22, 2011 5:57 am

Re: Using Argument with Space and Double Quote in check_nrpe

Post by phan »

Tried the single quote around the parameter value, didn't work either.

Tried the single quote around the entire sentence to be passed to the -a switch, didn't work either.

Tried to put the double quote around the $ARGS1 in nrpe.cfg, but that did not work either.

So I ended up hardcoding the parameter value in my script to bypass that, but I am sure there should/need to be a way to get around this.
User avatar
dpqmw80
Posts: 1
Joined: Sun Nov 20, 2011 12:48 pm
Location: Melbourne,VIC,Australia
Contact:

Re: Using Argument with Space and Double Quote in check_nrpe

Post by dpqmw80 »

space and double quotes work fine. you have to take care of single quotes, either exclude them or replace them with two double quotes at a time.
User avatar
jsmurphy
Posts: 989
Joined: Wed Aug 18, 2010 9:46 pm

Re: Using Argument with Space and Double Quote in check_nrpe

Post by jsmurphy »

Escaping parameters with the back slash does and should work... I'm just not sure why it's not behaving as expected in this instance :( .

At any rate at least you've found a solution for the time being.
Locked