Hi to everyone,
I would like to monitor a Windows Server taking advantage of Python scripts. The script are already located in the NCPA's plugins folder.
The services configuration in Nagios is set like the image in attachments.
The "Status information" error is: UNKNOWN: An error occured connecting to API. (HTTP error: '500 INTERNAL SERVER ERROR')
Do you have any tips?
When i do the same exactly thing with powershell i've no problems.
Thank you.
Python scripts
Python scripts
You do not have the required permissions to view the files attached to this post.
-
swolf
Re: Python scripts
Hi @RegIT, thanks for reaching out.
I think a 500 error from NCPA is always a bug - can you check ncpa_listener.log on your Windows server to see if there's any additional information we can pass along to the NCPA maintainer?
-Sebastian
I think a 500 error from NCPA is always a bug - can you check ncpa_listener.log on your Windows server to see if there's any additional information we can pass along to the NCPA maintainer?
-Sebastian
Re: Python scripts
Here the log
2024-06-27 16:59:08,331 listener.server ERROR Exception on /api/plugins/REGESTA.py/ [GET]
Traceback (most recent call last):
File "listener\nodes.py", line 351, in run_check
File "listener\nodes.py", line 315, in get_values
AttributeError: 'PluginNode' object has no attribute 'method'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "flask\app.py", line 1473, in wsgi_app
File "flask\app.py", line 882, in full_dispatch_request
File "flask\app.py", line 880, in full_dispatch_request
File "flask\app.py", line 865, in dispatch_request
File "listener\server.py", line 317, in token_auth_decoration
File "listener\server.py", line 1507, in api
File "listener\nodes.py", line 353, in run_check
File "listener\pluginnodes.py", line 122, in execute_plugin
File "gevent\subprocess.py", line 808, in __init__
File "gevent\subprocess.py", line 1295, in _execute_child
FileNotFoundError: [WinError 2] Impossibile trovare il file specificato
2024-06-27 16:59:08,331 listener.server ERROR Exception on /api/plugins/REGESTA.py/ [GET]
Traceback (most recent call last):
File "listener\nodes.py", line 351, in run_check
File "listener\nodes.py", line 315, in get_values
AttributeError: 'PluginNode' object has no attribute 'method'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "flask\app.py", line 1473, in wsgi_app
File "flask\app.py", line 882, in full_dispatch_request
File "flask\app.py", line 880, in full_dispatch_request
File "flask\app.py", line 865, in dispatch_request
File "listener\server.py", line 317, in token_auth_decoration
File "listener\server.py", line 1507, in api
File "listener\nodes.py", line 353, in run_check
File "listener\pluginnodes.py", line 122, in execute_plugin
File "gevent\subprocess.py", line 808, in __init__
File "gevent\subprocess.py", line 1295, in _execute_child
FileNotFoundError: [WinError 2] Impossibile trovare il file specificato
Re: Python scripts
Are you able to execute a simple python script (print('Hello World') for example) on the Windows Server with NCPA?
If not, are you able to execute it on the windows server manually with python?
There could be issues with your python pathing in your NCPA configuration (this seems like the most likely problem because powershell is working)
If not, are you able to execute it on the windows server manually with python?
There could be issues with your python pathing in your NCPA configuration (this seems like the most likely problem because powershell is working)
Re: Python scripts
When i try to execute a script i receive this alert
You do not have the required permissions to view the files attached to this post.
Re: Python scripts
Hi @RegIT, thanks for reaching out.
I am going to open a bug on Github, for this issue. It looks like you are running NCPA 3, is that correct?
Our NCPA maintainer is out this week, but will take a look at this when he returns.
I am going to open a bug on Github, for this issue. It looks like you are running NCPA 3, is that correct?
Our NCPA maintainer is out this week, but will take a look at this when he returns.
Please let us know if you have any other questions or concerns.
-Laura
-Laura
Re: Python scripts
I've managed this issue changing the ncpa.cfg modifying the string when calling the .py
I've changed from "python3 $plugin_name $plugin_args" to "python $plugin_name $plugin_args".
Now the script works but in the status information i see this:
Any tips?
I've changed from "python3 $plugin_name $plugin_args" to "python $plugin_name $plugin_args".
Now the script works but in the status information i see this:
Any tips?
You do not have the required permissions to view the files attached to this post.
Re: Python scripts
Hi @RegIT,
Thank you for the information. I am sure our NCPA maintainer will appreciate it.
If you are interested, the Github issue for the original problem is https://github.com/NagiosEnterprises/ncpa/issues/1179.
Googling a bit I found this somewhat recent post (unfortunately not for Windows) https://discuss.python.org/t/why-is-pyt ... ng/10565/7, that might help. The gist is to reinstall Python.
Thank you for the information. I am sure our NCPA maintainer will appreciate it.
If you are interested, the Github issue for the original problem is https://github.com/NagiosEnterprises/ncpa/issues/1179.
Googling a bit I found this somewhat recent post (unfortunately not for Windows) https://discuss.python.org/t/why-is-pyt ... ng/10565/7, that might help. The gist is to reinstall Python.
Please let us know if you have any other questions or concerns.
-Laura
-Laura