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

This forum is intended for the discussion of Nagios plugin development. Feature requests, patches, bug fixes, and all types of development-related discussions are welcome!

NOTE: The SourceForge.net nagiosplug-devel mailing list has been deprecated in favor of this forum in order to expedite support and provide additional features not available on the old mailing list.

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

Postby jardysx » Tue Jul 31, 2018 2:50 am

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

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

Postby lmiltchev » Wed Aug 01, 2018 9:04 am

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 47 times


For some reason, this doesn't work in all cases though. See the example below.

example02.PNG
example02.PNG (7.37 KiB) Viewed 47 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.
As of May 25th, 2018, all communications with Nagios Enterprises and its employees are covered under our new Privacy Policy.

Be sure to check out our Knowledgebase for helpful articles and solutions!
User avatar
lmiltchev
QA Manager
 
Posts: 10506
Joined: Mon May 23, 2011 12:15 pm


Return to Nagios Plugin Development

Who is online

Users browsing this forum: No registered users and 3 guests