Page 1 of 1

NCPA 2.0.2 plugin returns incorrect stdout

Posted: Fri Mar 17, 2017 1:43 pm
by corkyman
I am testing the new NCPA 2.0.2 agent and created a test plugin test.bat that echoes the supplied argument.
Under NCPA 1.8.1 the plugin returns {
"value": {
"returncode": 0,
"stdout": "hello"
}
}
Under NCPA 2.0.2 the plugin returns
{
"returncode": 0,
"stdout": "ECHO is off."
}

Please see the attached screen print.

Re: NCPA 2.0.2 plugin returns incorrect stdout

Posted: Fri Mar 17, 2017 2:09 pm
by mcapra
Arguments for scripts are being changed for 2.1.0 to work a little bit better. See this github issue (and feel free to chime in if you like):
https://github.com/NagiosEnterprises/ncpa/issues/316

I was able to replicate this behavior consistently on my Windows machine.

Re: NCPA 2.0.2 plugin returns incorrect stdout

Posted: Mon Mar 20, 2017 6:52 am
by corkyman
It does not feel like these problems are related. I updated the plugin not to require an argument (so no slashes) and got the same result. Please see attached.

Re: NCPA 2.0.2 plugin returns incorrect stdout

Posted: Mon Mar 20, 2017 12:57 pm
by lmiltchev
What is the plugin's version that you are currently using? You can view it by running the following command from the command line:

Code: Select all

/usr/local/nagios/libexec/check_ncpa.py -V
I haven't been able to recreate the issue (I am running NCPA agent 2.0.3). Here's what I tried:

1st test (without passing arguments)

test.bat

Code: Select all

@echo off
echo hello
In the GUI:
example01.PNG
2nd test (with passing one argument)

test2.bat

Code: Select all

@echo off
echo %1
In the GUI:
example02.PNG
I have tried both, the "new" API endpoint (plugins), and the "old" (deprecated) API endpoint (agent/plugin). Both seemed to work just fine for me:

Examples:

Code: Select all

https://192.168.x.x:5693/api/plugins/test.bat
https://192.168.x.x:5693/api/plugins/test2.bat
https://192.168.x.x:5693/api/agent/plugin/test.bat
https://192.168.x.x:5693/api/agent/plugin/test2.bat

Re: NCPA 2.0.2 plugin returns incorrect stdout

Posted: Tue Mar 21, 2017 8:16 am
by corkyman
I am not using the check_ncpa.py. Executing the test.bat plugin through the browser interface. I will load 2.0.3 and recheck.

Re: NCPA 2.0.2 plugin returns incorrect stdout

Posted: Tue Mar 21, 2017 8:45 am
by corkyman
Could you run your https execution examples in the browser instead of a GUI and include the argument? I think you will be able to reproduce the problem using the deprecated API format.

I tested 2.0.3 and see that
1. Running the test.bat plugin without arguments works with an old API format (it did not in 2.0.2)
2. Running test.bat plugin with an argument works using the new API format.
3. Running test.bat with an argument using old API format does not work. I believe it is the same error as mentioned at the beginning of this incident--parsing of slashes.
NCPA has problem recognizing that /hello is an argument and tries to download it, then creates a 'hello' file. Please see the screen prints.

Re: NCPA 2.0.2 plugin returns incorrect stdout

Posted: Tue Mar 21, 2017 10:12 am
by lmiltchev
3. Running test.bat with an argument using old API format does not work.
Actually, you are correct. The second time I tried this, I was able to recreate the issue. Having said that, "agent/plugin" will be removed soon in favor of "plugins", so that shouldn't be an issue. You are however welcome to file a bug report (if you wish) here:

https://github.com/NagiosEnterprises/ncpa/issues

Re: NCPA 2.0.2 plugin returns incorrect stdout

Posted: Tue Mar 21, 2017 4:36 pm
by corkyman
Well, I wish there was an easier way to make a bug report out of this incident. I will make it an awareness item for myself and my group instead. Please close this incident. Thank you for your help.