Page 1 of 1

Using Argument with Space and Double Quote in check_nrpe

Posted: Tue Nov 22, 2011 6:04 am
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.

Re: Using Argument with Space and Double Quote in check_nrpe

Posted: Tue Nov 22, 2011 4:17 pm
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.

Re: Using Argument with Space and Double Quote in check_nrpe

Posted: Tue Nov 22, 2011 8:35 pm
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.

Re: Using Argument with Space and Double Quote in check_nrpe

Posted: Wed Nov 23, 2011 5:28 pm
by jsmurphy
Oh I see I missed the first set of quotes... does single quoting the inner set work? I.e. 'AA 001' instead

Re: Using Argument with Space and Double Quote in check_nrpe

Posted: Wed Nov 23, 2011 9:27 pm
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.

Re: Using Argument with Space and Double Quote in check_nrpe

Posted: Thu Nov 24, 2011 1:56 pm
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.

Re: Using Argument with Space and Double Quote in check_nrpe

Posted: Thu Nov 24, 2011 4:33 pm
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.