Python Skript on Windows Server doesent Work via Icinga

Hello Icinga Community,

I created a python script on a Windows host with an Icinga client installed. This script works very well when started locally on the server. This error occurs when it is started via Icinga:

Command “C:\Program Files\ICINGA2/sbin/check_login.py” --hostname xxxxx failed to execute: 193, “%1 ist keine zul?ssige Win32-Anwendung.”

The other checks carried out by the agent such as disk RAM etc. work very well.

Does anyone know the solution to this problem?
What information can I provide so that the problem can be better identified?

Thanks in Advance.

Hello @tom2!

I guess your check command contains something like this:

  command = [ "C:\\Program Files\\ICINGA2/sbin/check_login.py" ]

Have you tried to adjust it as follows?

  command = [ "C:\\Program Files\\PATH\\TO\\YOUR\\PYTHON\\INTERPRETER.EXE", "C:\\Program Files\\ICINGA2/sbin/check_login.py" ]

Best,
AK

Hi :slight_smile:

Thanks for your reply. I tried already Several things. But I was not aware that I have to write in this Style.
This is the result:

Command “C:\Program Files\ICINGA2/sbin/“C:\Program” “Files\python.exe”,​” ““C:\Program” “Files\ICINGA2/sbin/check_login.py”” --hostname xxxxx failed to execute: 5, “Zugriff verweigert”

It means: Access denied.

Its a windows Server 2016 and py script is executable for everbody.

Do you have frurther Ideas how I can solve this issue?

When you run that script locally it’s done under the security context of the logged in user e.g. Administrator. When icinga executes the script it’s done under the security context of the icinga agent which is by default “Network Service”.

Thanks Roland. Can Icinga execute the script as administrator?
Can I change this in the Icinga director?

Director does not help here at all. You could run the icinga agent with administrator’s security context (which is not the best idea from security perspective) or create a wrapper script e.g. with runas option (which challenges you to hide administrator’s password).

Thanks for your answers :slightly_smiling_face:

Although Icinga told from a permission problem it was a other problem.
With a Python installation path without blank in this style it’ working:
C:\python3\python.exe “C:\Program Files\ICINGA2/sbin/check_login.py”