NCPA fails if there are spaces in argument -a -q

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
jardysx
Posts: 1
Joined: Thu Jul 26, 2018 9:31 am

NCPA fails if there are spaces in argument -a -q

Post by jardysx »

I tried running a script with ncpa.
NCPA agent version 2.1.5
check_ncpa.py version 1.1.3

Working:
/check_ncpa.py -t 'mytoken' -H X.X.X.X -P 5693 -M 'plugins/check_winfile.exe' -q 'args=--target C:\Test\,args=--compare eq,args=--critical 2'
/check_ncpa.py -t 'mytoken' -H X.X.X.X -P 5693 -M 'plugins/check_winfile.exe' -a '--target C:\Test\ --compare eq --critical 2'

Doesn't working:
/check_ncpa.py -t 'mytoken' -H X.X.X.X -P 5693 -M 'plugins/check_winfile.exe' -q 'args=--target C:\Program Files (x86)\Nagios\test.txt,args=--filter age lt -8 hours,args=--critical 0'
/check_ncpa.py -t 'mytoken' -H X.X.X.X -P 5693 -M 'plugins/check_winfile.exe' -a "--target 'C:\Program Files (x86)\Nagios\test.txt' --filter 'age lt -8 hours' --critical '0'"

I think the problem is with arguments -a and -q when there is a space. "Program Files (x86)" "age lt -8 hours".

I read in discussions about a similar problem with the -m argument. https://github.com/NagiosEnterprises/ncpa/issues/14
User avatar
lmiltchev
Former Nagios Staff
Posts: 13587
Joined: Mon May 23, 2011 12:15 pm

Re: NCPA fails if there are spaces in argument -a -q

Post by lmiltchev »

In this particular case, I am not convinced that this is a NCPA problem. The plugin itself has some issues with spaces in the path... When I test it locally, on a Windows machine, the plugin handles well paths with no spaces. However, it fails to produce the expected output when there is a space ("TEMP" vs "MY TEMP"). This can be fixed by wrapping the path in double quotes.
example01.PNG
example01.PNG (8.34 KiB) Viewed 1559 times
For some reason, this doesn't work in all cases though. See the example below.
example02.PNG
example02.PNG (7.37 KiB) Viewed 1559 times
In this case, it was not enough to wrap the path in double quotes. In order to make it work, I had to escape backslashes. We will need to do some more testing, and see if we can make this work with NCPA.

Note: I haven't been able to find a solution yet, but just wanted to give you heads up, and let you know of my findings.
Be sure to check out our Knowledgebase for helpful articles and solutions!
Locked