NCPA 2.0.2 plugin returns incorrect stdout

This support forum board is for support questions relating to Nagios XI, our flagship commercial network monitoring solution.
Locked
corkyman
Posts: 120
Joined: Wed Jul 13, 2016 12:58 pm

NCPA 2.0.2 plugin returns incorrect stdout

Post 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.
You do not have the required permissions to view the files attached to this post.
User avatar
mcapra
Posts: 3739
Joined: Thu May 05, 2016 3:54 pm

Re: NCPA 2.0.2 plugin returns incorrect stdout

Post 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.
Former Nagios employee
https://www.mcapra.com/
corkyman
Posts: 120
Joined: Wed Jul 13, 2016 12:58 pm

Re: NCPA 2.0.2 plugin returns incorrect stdout

Post 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.
You do not have the required permissions to view the files attached to this post.
User avatar
lmiltchev
Bugs find me
Posts: 13589
Joined: Mon May 23, 2011 12:15 pm

Re: NCPA 2.0.2 plugin returns incorrect stdout

Post 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
You do not have the required permissions to view the files attached to this post.
Be sure to check out our Knowledgebase for helpful articles and solutions!
corkyman
Posts: 120
Joined: Wed Jul 13, 2016 12:58 pm

Re: NCPA 2.0.2 plugin returns incorrect stdout

Post 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.
corkyman
Posts: 120
Joined: Wed Jul 13, 2016 12:58 pm

Re: NCPA 2.0.2 plugin returns incorrect stdout

Post 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.
You do not have the required permissions to view the files attached to this post.
User avatar
lmiltchev
Bugs find me
Posts: 13589
Joined: Mon May 23, 2011 12:15 pm

Re: NCPA 2.0.2 plugin returns incorrect stdout

Post 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
Be sure to check out our Knowledgebase for helpful articles and solutions!
corkyman
Posts: 120
Joined: Wed Jul 13, 2016 12:58 pm

Re: NCPA 2.0.2 plugin returns incorrect stdout

Post 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.
Locked