Page 1 of 1
Ampersand in argument breaking check
Posted: Fri Oct 23, 2015 3:29 am
by WillemDH
Hello,
it seems when I'm using an ampersand in an argument, the check is not working and I get an EOF error.
This is in $ARG1$:
Code: Select all
-e 200 -u '/energieboekhouding/erbisweb.dll?topage=index2.htm' --post='inputuser=ADMIN&inputpassword=blabla' --useragent='Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/42.0.2311.90 Safari/537.36' -r 'Ongeldige' --invert-regex
I'm getting this as error:
Code: Select all
(No output on stdout) stderr: /bin/sh: -c: line 0: unexpected EOF while looking for matching `''
/bin/sh: -c: line 1: syntax error: unexpected end of file
Further testing showed that Nagios seems to only count everything before the '&' in my --post parameter.
I tried escaping the ampersand, but it didn't work.
Any suggestions so I can use ampersand & in my ARGs?
Grtz
Willem
Re: Ampersand in argument breaking check
Posted: Fri Oct 23, 2015 9:11 am
by BanditBBS
Replace the & with %26 and try again

Re: Ampersand in argument breaking check
Posted: Fri Oct 23, 2015 9:17 am
by SteveBeauchemin
I use & with no problems. I use the double quote around it. I see that you tried the single quote.
Steve B
Re: Ampersand in argument breaking check
Posted: Fri Oct 23, 2015 9:19 am
by rkennedy
Thanks
@BanditBBS! Did this work for you Willem?
Re: Ampersand in argument breaking check
Posted: Tue Oct 27, 2015 2:51 am
by WillemDH
Thanks for the help fellow nagios peoples, but I still seem to have issues..
Tried
Code: Select all
-e 200 -u '/energieboekhouding/erbisweb.dll?topage=index2.htm' --post='inputuser=ADMINUSER%26inputpassword=password' --useragent='Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/42.0.2311.90 Safari/537.36' -r 'Ongeldige' --invert-regex
Code: Select all
-e 200 -u '/energieboekhouding/erbisweb.dll?topage=index2.htm' --post="inputuser=ADMINUSER%26inputpassword=password" --useragent='Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/42.0.2311.90 Safari/537.36' -r 'Ongeldige' --invert-regex
Code: Select all
-e 200 -u '/energieboekhouding/erbisweb.dll?topage=index2.htm' --post="inputuser=ADMINUSER&inputpassword=password" --useragent='Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/42.0.2311.90 Safari/537.36' -r 'Ongeldige' --invert-regex
I keep getting:
Code: Select all
(No output on stdout) stderr: /bin/sh: -c: line 0: unexpected EOF while looking for matching `''
/bin/sh: -c: line 1: syntax error: unexpected end of file
Why on earth is it so hard to configure such a simple thing, which works perfect in cli? Any other suggestions to make this work?
Grtz
Re: Ampersand in argument breaking check
Posted: Tue Oct 27, 2015 8:08 am
by BanditBBS
You know, if I would have paid attention and seen this is for check_http, I would have not suggested what I did.
What's the command definition look like and the actual arguments on the service?
Re: Ampersand in argument breaking check
Posted: Tue Oct 27, 2015 9:47 am
by SteveBeauchemin
I do not have this issue with ampersand. But I did need to use exclamation points in commands before.
To get around that I added to the /usr/local/nagios/etc/resource.cfg file.
#
#Escaping exclamation points
$USER9$=!
Then used $USER9$ in the command where I needed the ! to be.
Maybe you could try adding a variable for the & and see if that lets you run it.
I did mine because it ran fine from the cli but not in the defined command. Similar scenario, different issue.
maybe add
#Escaping ampersand
$USER10$=&
so...
Code: Select all
-e 200 -u '/energieboekhouding/erbisweb.dll?topage=index2.htm' --post='inputuser=ADMIN$USER10$inputpassword=blabla' --useragent='Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/42.0.2311.90 Safari/537.36' -r 'Ongeldige' --invert-regex
There has to be a workaround for you.
Steve B
Re: Ampersand in argument breaking check
Posted: Tue Oct 27, 2015 12:23 pm
by WillemDH
Thanks for the help (again) Steve and Bandit
Seems it also works without the --useragent in cli so I left that out (had some issues in the past with that)
The command used it check_xi_service_http and the full command is
Code: Select all
$USER1$/check_http -t 40 -H $HOSTADDRESS$ $ARG1$
$ARG1$ you can find above.
I tried your suggestion and added
to /usr/local/nagios/etc/resource.cfg
Changed ARG1 to:
Code: Select all
-e 200 -u '/energieboekhouding/erbisweb.dll?topage=index2.htm' --post="inputuser=ADMIN$USER10$inputpassword=blabla" -r 'Ongeldige' --invert-regex
And it works!
Thanks all!
@Nagios please close