Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Windows Server HTTP error: '500 INTERNAL SERVER ERROR' running python plugins #1179

Closed
ne-lgute opened this issue Jun 27, 2024 · 4 comments
Closed

Comments

@ne-lgute
Copy link

Issue reported by Forums user at https://support.nagios.com/forum/viewtopic.php?p=357509#p357509

Error running custom python plugins.

The "Status information" error is: UNKNOWN: An error occured connecting to API. (HTTP error: '500 INTERNAL SERVER ERROR')

ncpa_listener.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
@MrPippin66
Copy link

What is your plugin config settings in your ncpa.cfg file?

@FrancescodeRosa-Reg
Copy link

I'm using the command $USER1$/check_ncpa.py and i'm trying to call a remote pythons cript from a Windows Server.

I've changed recently the defaults extension for .py and now the scripts works but in nagios i've got a problem with the "Status information" as you can see in the attachments

Plugin Configuration
# -------------------------------
#

[plugin directives]

#
# Plugin path where all plugins will be run from.
#
plugin_path = plugins/

#
# Follow symlinks located in the plugin path
#
# This is for Unix only (Linux, Mac OS X, etc)
#
follow_symlinks = 0

#
# Plugin execution timeout in seconds. Different than the check_ncpa.py timeout, which is
# normally for network connection issues. Will return a CRITICAL value and error when the plugin
# reaches the defined max execution timeout and kills the process.
# Default: 59
#
# plugin_timeout = 59

#
# Comma separated list of plugins to run through sudo. Note: You will need to update your sudoers
# configuration for these plugins to work when called with sudo.
#
# Example: check_special,check_root_files
# (Command line: sudo /<plugin_absolute_path>/check_special <arguments>)
#
# This is for Unix only (Linux, Mac OS X, etc)
#
# run_with_sudo =

#
# Extensions for plugins
# ----------------------
# The extension for the plugin denotes how NCPA will try to run the plugin. Use this
# for setting how you want to run the plugin in the command line.
#
# NOTE: Plugins without an extension will be run in the cmdline as follows:
#       $plugin_name $plugin_args
#
# Defaults:
# .sh = /bin/sh $plugin_name $plugin_args
# .py = python3.12 $plugin_name $plugin_args
# .pl = perl $plugin_name $plugin_args
# .php = php $plugin_name $plugin_args
# .ps1 = powershell -ExecutionPolicy Bypass -File $plugin_name $plugin_args
# .vbs = cscript $plugin_name $plugin_args //NoLogo
# .wsf = cscript $plugin_name $plugin_args //NoLogo
# .bat = cmd /c $plugin_name $plugin_args
#

# Linux / Mac OS X
.sh = /bin/sh $plugin_name $plugin_args
.py = python $plugin_name $plugin_args
.pl = perl $plugin_name $plugin_args
.php = php $plugin_name $plugin_args

# Windows
.ps1 = powershell -ExecutionPolicy Bypass -File $plugin_name $plugin_args
.vbs = cscript $plugin_name $plugin_args //NoLogo
.wsf = cscript $plugin_name $plugin_args //NoLogo
.bat = cmd /c $plugin_name $plugin_args

status

status2

@ne-bbahn
Copy link
Contributor

ne-bbahn commented Oct 1, 2024

Hello @FrancescodeRosa-Reg, do you have python 2 installed on that machine? Try running python --version (on your NCPA machine) and see if it links to Python 2 or 3.
You may have a python build issue. Are you building NCPA yourself? There was a period where cx_Freeze had updated, but I hadn't yet fixed NCPA, which was causing the init_fs_encoding error.

I recommend backing up your configs/plugins and trying to reinstall with the latest version of NCPA.

@FrancescodeRosa-Reg
Copy link

FrancescodeRosa-Reg commented Oct 2, 2024 via email

@ne-bbahn ne-bbahn closed this as completed Oct 2, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants