Page 1 of 1

CUSTOM_PLUGIN

Posted: Mon Jul 27, 2020 8:12 am
by yybadrou
Hello,

I am using Nagios XI and I am monitoring a Windows Host with NCPA client.
I have developed a python script which give me if a licence of one of the software installed on this windows machine is up to date or not.

My script is named "check_opc.py" and it takes 3 arguments -s $ARG1$ -n $ARG2$ and -v $ARG3$

On my windows machine, using PowerShell when I execute this plugin like that :
C:\Program Files\Nagios\NCPA\plugins> python .\check_opc.py -s opc.tcp://127.0.0.1:49320 -n "ns=2;s=_System._LicensedFeatures" -v "['Allen-Bradley ControlLogix Ethernet']"
This is the output that I get (it is correct)
Unable to read ['Allen-Bradley ControlLogix Ethernet'] in node ns=2;s=_System._LicensedFeatures from opc.tcp://127.0.0.1:49320

I want to see this output on my Nagios Server GUI

I Have my custom plugin in the NCPA plugins directory of the client(windows). However, I can't run the pluging remotely from Nagios. Here is the command that I am using


root@ubuntu:/usr/local/nagios/libexec# ./check_ncpa.py -H ServerAddressNCPA -t mytoken -P 5693 -M 'plugins/check_opc.py' -a '-s opc.tcp://127.0.0.1:49320 -n "ns=2;s=_System._LicensedFeatures" -v "['Allen-Bradley ControlLogix Ethernet']"'

but I got this error:
UNKNOWN: Error occurred while running the plugin. Use the verbose flag for more details.


I have tried so many ways to write the command in different ways, but nothing seems to be resolving the problem. ANY HELP !!!!!!!!!

Thank you

Re: CUSTOM_PLUGIN

Posted: Mon Jul 27, 2020 1:50 pm
by benjaminsmith
Hi,

I would check the NCPA log on the Windows host for more information. If there are any errors, please post them to the thread for us to review.

See: https://www.nagios.org/ncpa/help/2.0/configuration.html

Also, try to change the plugin path in the ncpa.cfg as maybe it's not executing correctly. Remember to restart the NCPA service after making any changes.

Code: Select all

.py = C:\Python27\python.exe $plugin_name $plugin_args
https://github.com/NagiosEnterprises/ncpa/issues/478

Re: CUSTOM_PLUGIN

Posted: Tue Jul 28, 2020 4:16 am
by yybadrou
Hi,

I have successed to execute my pluging locally from the NCPA Client API as you can see
ncpa client.png
But when I try to execute it from Nagios to check the result, I proceed as follow:
nagios req.png
An this is the error I receive, It is an error in the execution of the script:
nagios res.png
How it can be possible for the script to be executed from the client and not from the Nagios Server, I think that it's just like he is not detecting my first argument. ANY IDEAS for this problem ?

Thanks,

Re: CUSTOM_PLUGIN

Posted: Tue Jul 28, 2020 3:26 pm
by benjaminsmith
Hi,

It's calling the plugin so that's good, but it's not able to read the arguments. Try wrapping arguments 2-4 in single quotes, and let me know if that resolves the issue. For example:

Code: Select all

-s 'opc.tcp://127.0.0.1:49320'
-n 'ns=2;s=_System._LicensedFeatures'
 -v '["Allen-Bradley ControlLogix Ethernet"]'

Re: CUSTOM_PLUGIN

Posted: Thu Jul 30, 2020 2:16 am
by yybadrou
Hi,


I resolved the issue. Thank you so much for your help.

The issue was resolved as follow, I stoped trying to run the command from the Nagios Server CLI. Instead i tried to delete my host completly from my Nagios, and try to add it again. But this is what I have done in the configuration Wizzard
Capture d’écran 2020-07-30 à 9.12.11 AM.png
As you can see in the argument textfield this is what I did. I have deleted all the quotes :
-s opc.tcp://127.0.0.1:49320 -n ns=2;s=_System._LicensedFeatures -v [Allen-Bradley ControlLogix Ethernet]

And finally the plugin seems to be working very well:
Capture d’écran 2020-07-28 à 3.46.52 PM.png
Thank you !

Re: CUSTOM_PLUGIN

Posted: Thu Jul 30, 2020 6:57 am
by scottwilkerson
yybadrou wrote:Hi,


I resolved the issue. Thank you so much for your help.

The issue was resolved as follow, I stoped trying to run the command from the Nagios Server CLI. Instead i tried to delete my host completly from my Nagios, and try to add it again. But this is what I have done in the configuration Wizzard
Capture d’écran 2020-07-30 à 9.12.11 AM.png
As you can see in the argument textfield this is what I did. I have deleted all the quotes :
-s opc.tcp://127.0.0.1:49320 -n ns=2;s=_System._LicensedFeatures -v [Allen-Bradley ControlLogix Ethernet]

And finally the plugin seems to be working very well:
Capture d’écran 2020-07-28 à 3.46.52 PM.png
Thank you !
Glad you were able to resolve the issue and thanks for sharing your results!

Locking thread