How to add Python 3.X Script to Nagios Core

Support forum for Nagios Core, Nagios Plugins, NCPA, NRPE, NSCA, NDOUtils and more. Engage with the community of users including those using the open source solutions.
Locked
chunye
Posts: 2
Joined: Thu Dec 06, 2018 6:42 pm

How to add Python 3.X Script to Nagios Core

Post by chunye »

The Nagios version is Nagios® Core™ 3.2.3 and the NSClient Version is NSClient++ 0.5.2.35 2018-01-28.
I want to add a Python 3.X Script to Nagios Core.
I have copied all needed Python libs which include urllib3 to C:\Python37\Lib\site-packages on the Windows Server 2012 by following https://docs.nsclient.org/extending/python/.
But I will meet below error when running "nscp py add --script my_script.py".
The Python script to be added(get_ata_lastupdate.py) can run successfully under Python 3.7 after installing urllib3/requests_ntlm, etc.

-->>Error message:
C:\Program Files\NSClient++>nscp py add --script d:\CC\ScriptByXuChunye\InstalledPythonLibs\get_ata_lastupdate.py
E python Failed to load script: d:\CC\ScriptByXuChunye\InstalledPythonLibs\get_ata_lastupdate.py
c:\source\master\modules\PythonScript\python_script.cpp:237
Added get_ata_lastupdate as d:\CC\ScriptByXuChunye\InstalledPythonLibs\get_ata_lastupdate.py
E python Traceback (most recent call last):
File "d:\CC\ScriptByXuChunye\InstalledPythonLibs\get_ata_lastupdate.py", line 3, in <module>
import urllib3
ImportError: No module named urllib3

c:\source\master\modules\PythonScript\script_wrapper.cpp:171
E python Failed to load script: d:\CC\ScriptByXuChunye\InstalledPythonLibs\get_ata_lastupdate.py
c:\source\master\modules\PythonScript\python_script.cpp:237
E python Traceback (most recent call last):
File "d:\CC\ScriptByXuChunye\InstalledPythonLibs\get_ata_lastupdate.py", line 3, in <module>
import urllib3
ImportError: No module named urllib3

c:\source\master\modules\PythonScript\script_wrapper.cpp:171

C:\Program Files\NSClient++>

Can anyone give a comment or suggestion? Thanks!
Locked