Embedded white space in nagios arguments

nagios

I created my own nagios command

$USER1$/check_http -H $HOSTNAME$ -p $ARG1$ -u $ARG2$ -e $ARG3$ -w 5 -c 10 -4

used by a new service.

When the $ARG3$ contains some white space (for instance "200 OK") the service fail reporting "name or service not known". As in the following command line:

check_http -H 1.1.1.1 -u /xxx/1234.pdf -w 5 -c 10 -e 200 OK   
Name or service not known

How can I quote the white space in some way?

Best Answer

On the command line, just quote it

[me@nagios ~]$ /usr/lib64/nagios/plugins/check_http -H www.teaparty.net -u http://www.teaparty.net/index.html -w 5 -c 10 -e "200 OK"  
HTTP OK: Status line output matched "200 OK" - 10522 bytes in 0.029 second response time |time=0.029431s;5.000000;10.000000;0.000000 size=10522B;;;0

In the NAGIOS config file, merely separating it from $ARG2$ with a ! should be enough to protect it; in my experience, NAGIOS will generally protect spaces. If that doesn't work, quote it in $ARG3$ also.