What is this?

This knowledgebase contains questions and answers about PRTG Network Monitor and network monitoring in general.

Learn more

PRTG Network Monitor

Intuitive to Use. Easy to manage.
More than 500,000 users rely on Paessler PRTG every day. Find out how you can reduce cost, increase QoS and ease planning, as well.

Free Download

Top Tags


View all Tags

Windows WSL bash.exe call

Votes:

0

Hello,

quite a while ago i used Cygwin to run sh/bash scripts as custom sensors for PRTG. My setup is similar to this kb https://kb.paessler.com/en/topic/60017-custom-sensor-bash-script

Now i want to use the "Windows Subsystem for Linux" feature in Windows 10 instead of Cygwin. I made sure the PRTG service runs under the same user as i used to setup WLS (Ubuntu). I changed the batch file accordingly "'c:\cygwin64\bin\bash.exe -l -c" -> "'c:\windows\system32\bash.exe -l -c" and verified it's working by executing it in cmd terminal.

Unfortunately i only get an error message in PRTG (response not well formed) "Antwort nicht wohlgeformt: "(Der Befehl "C:\Windows\System32\bash.exe" ist entweder falsch geschrieben oder konnte nicht gefunden werden. ECHO ist ausgeschaltet (OFF). )" (Code: PE132)"

However. If i copy bash.exe into the EXE folder (Custom Sensors) and write the whole -l -c ... string as parameter into the sensor, it works.

Any idea? I could use it with direct bash.exe command, but it would be nice to be able to just specify the script with its parameters or path.

bash-exe batch custom

Created on Oct 17, 2018 1:00:10 PM



10 Replies

Votes:

0

Hi there,

When you use the EXE/Script or EXE/Script Advanced Sensor, you are able to submit any parameters you want:
https://www.paessler.com/manuals/prtg/exe_script_sensor
https://www.paessler.com/manuals/prtg/exe_script_advanced_sensor

Have you tried that?

Best regards.

Created on Oct 18, 2018 6:44:30 PM by  Dariusz Gorka [Paessler Support]



Votes:

0

THX for the reply, but i think you misunderstood my "problem". I have no issue calling a program / scrip with additional parameters. It's just that running a batch scrip callung bash.exe fails while running bash.exe directly works. The issue with directly running bash.exe is that i have to provide more parameters that are the same for all custom script sensors.

Created on Oct 18, 2018 8:54:37 PM



Votes:

0

Hi there,

Do you execute the custom script like this:

PRTG > .BAT File > bash.exe

Or like this

PRTG > bash.exe

At what point do you need to provide more parameters and what keeps you from providing these?

Best regards.

Created on Oct 23, 2018 8:49:28 AM by  Dariusz Gorka [Paessler Support]



Votes:

0

Hey Dariusz,

with Cygwin i used PRTG > -BAT File > bash.exe
I would like to keep it that way using WSL, but i only get the above mentioned error.

So currently i use PRTG > bash.exe

If i use PRTG > bash.exe i need to call it like that:

bash.exe -l -c "/usr/local/scripts/some_script.sh param-1 param-n"

If i can use PRTG > BAT File > bash.exe, i can solely focus on the actual scripts
bash.bat
some_script.sh param-1 param-n

Tha later also has the advantage that i can have installations that differ from each other (like script files in /usr/local/some_other_folder/same_script_name.sh, which is important if i want to move/copy sensors/devices to other probes (without the need of checking how scripts are executed at that particular remote probe)

I hope this is now clear enough :D

Created on Oct 25, 2018 8:27:23 AM

Last change on Oct 25, 2018 10:09:54 AM by  Dariusz Gorka [Paessler Support]



Votes:

0

Hi there,

Most likely the reason for the error is, that the script is executed under the SYSTEM user and the directory where the batch starts is "C:\Windows\System32\". So in this case when you only call "bash.exe", the commandline expects this exe to be available in the very same directory. Could you check if the "bash.exe" is really present in the "C:\Windows\System32\" directory?

Best regards.

Created on Oct 25, 2018 10:12:24 AM by  Dariusz Gorka [Paessler Support]



Votes:

0

Hey Dariusz,

the PRTG service runs unser dedicated administrative user (not SYSTEM). I monitor Veeam Backup with a powershell script that needs to run as that specific user (for authentication purposes) and it works.

C:\Windows\System32\bash.exe does exist. In fact i copied it from there to the EXE folder in order to run it directly without the .bat file.

Created on Oct 25, 2018 1:54:05 PM



Votes:

0

Hi there,

To check this, please add a File Sensor (https://www.paessler.com/manuals/prtg/file_sensor) under the Probe device and use the path "C:\Windows\System32\bash.exe". Does that File Sensor work?

Best regards.

Created on Oct 30, 2018 11:23:31 AM by  Dariusz Gorka [Paessler Support]



Votes:

0

Hey Dariusz,

thank you for that suggestion. I think i found the problem, maybe, kinda :D

The File Sensor returned "Impersonation was denied (code: PE180)" which seems to be related to a bug in PRTG presented in this thread: https://kb.paessler.com/en/topic/79162-impersonation-was-denied-code:-pe180

According to this thread it should befixed around May Quote: "There will be a bug fix in version 18.x.40. The release is planned for mid-May." Maybe it hasn't ben fixed yet?

I made a workaround by pointing to the bash.exe in the Custom Sensors\EXE folder (c:\PROGRA2\PRTGNE1\CUSTOM1\EXE\bash.exe). And it works :)

Created on Oct 30, 2018 1:22:04 PM



Votes:

0

Hi there,

I have forgotten that you should add valid Windows Credentials into the device settings that are also available on the Core Server itself, might that be the case?

Best regards.

Created on Oct 30, 2018 1:27:54 PM by  Dariusz Gorka [Paessler Support]



Votes:

0

Hey Dariusz,

credentials have alwayse been present.

Created on Nov 2, 2018 12:49:05 PM




Disclaimer: The information in the Paessler Knowledge Base comes without warranty of any kind. Use at your own risk. Before applying any instructions please exercise proper system administrator housekeeping. You must make sure that a proper backup of all your data is available.