Ampersand in argument breaking check

This support forum board is for support questions relating to Nagios XI, our flagship commercial network monitoring solution.
Locked
User avatar
WillemDH
Posts: 2320
Joined: Wed Mar 20, 2013 5:49 am
Location: Ghent
Contact:

Ampersand in argument breaking check

Post 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
Nagios XI 5.8.1
https://outsideit.net
User avatar
BanditBBS
Posts: 2474
Joined: Tue May 31, 2011 12:57 pm
Location: Scio, OH
Contact:

Re: Ampersand in argument breaking check

Post by BanditBBS »

Replace the & with %26 and try again :)
2 of XI5.6.14 Prod/DR/DEV - Nagios LogServer 2 Nodes
See my projects on the Exchange at BanditBBS - Also check out my Nagios stuff on my personal page at Bandit's Home and at github
SteveBeauchemin
Posts: 524
Joined: Mon Oct 14, 2013 7:19 pm

Re: Ampersand in argument breaking check

Post by SteveBeauchemin »

I use & with no problems. I use the double quote around it. I see that you tried the single quote.

Steve B
XI 5.7.3 / Core 4.4.6 / NagVis 1.9.8 / LiveStatus 1.5.0p11 / RRDCached 1.7.0 / Redis 3.2.8 /
SNMPTT / Gearman 0.33-7 / Mod_Gearman 3.0.7 / NLS 2.0.8 / NNA 2.3.1 /
NSClient 0.5.0 / NRPE Solaris 3.2.1 Linux 3.2.1 HPUX 3.2.1
rkennedy
Posts: 6579
Joined: Mon Oct 05, 2015 11:45 am

Re: Ampersand in argument breaking check

Post by rkennedy »

Thanks @BanditBBS! Did this work for you Willem?
Former Nagios Employee
User avatar
WillemDH
Posts: 2320
Joined: Wed Mar 20, 2013 5:49 am
Location: Ghent
Contact:

Re: Ampersand in argument breaking check

Post 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
Nagios XI 5.8.1
https://outsideit.net
User avatar
BanditBBS
Posts: 2474
Joined: Tue May 31, 2011 12:57 pm
Location: Scio, OH
Contact:

Re: Ampersand in argument breaking check

Post 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?
2 of XI5.6.14 Prod/DR/DEV - Nagios LogServer 2 Nodes
See my projects on the Exchange at BanditBBS - Also check out my Nagios stuff on my personal page at Bandit's Home and at github
SteveBeauchemin
Posts: 524
Joined: Mon Oct 14, 2013 7:19 pm

Re: Ampersand in argument breaking check

Post 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
XI 5.7.3 / Core 4.4.6 / NagVis 1.9.8 / LiveStatus 1.5.0p11 / RRDCached 1.7.0 / Redis 3.2.8 /
SNMPTT / Gearman 0.33-7 / Mod_Gearman 3.0.7 / NLS 2.0.8 / NNA 2.3.1 /
NSClient 0.5.0 / NRPE Solaris 3.2.1 Linux 3.2.1 HPUX 3.2.1
User avatar
WillemDH
Posts: 2320
Joined: Wed Mar 20, 2013 5:49 am
Location: Ghent
Contact:

Re: Ampersand in argument breaking check

Post 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

Code: Select all

$USER10$=&
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
Nagios XI 5.8.1
https://outsideit.net
Locked