I've written a CMD file as a PRTG sensor to check a temperature sensor that has a simple text web page that reports the temperature in a rack of equipment.

Here's my script: {{{@echo off for /F "tokens=1,3* delims=| " %%i in ('c:\windows\system32\curl.exe -s http://url.local.lan/temp') do set temperature=%%j

if %temperature% gtr 82 goto error if %temperature% gtr 78 goto warning if %temperature% gtr 60 goto good

:: catch all for anything under 60 echo %temperature%:Other exit 3

:error echo %temperature%:Error pause exit 2

:warning echo %temperature%:Warning pause exit 1

:good echo %temperature%:Ok pause exit 0}}}

I can run it from the command line on the probe and it works perfectly. I've put the curl.exe into the path (c:\windows\system32) and called it both by full path, and just by name (i.e. "curl").

I've tested with the PRTG probe running as my own admin user account. Each time i get the error:

'c:\windows\system32\curl.exe' is not recognized as an internal or external command, operable program or batch file.

I've tried moving my EXE commands to variables like this: for /F "tokens=1,3* delims=| " %%i in ('%1 %2 %3') do set temperature=%%j And then pass the parameters from within PRTG sensor setting, but get the same error.

PRTG Sensor is set to run as "Use security context of probe service"

NOTE: I attempted to use PowerShell and "Invoke-WebRequest" but the temperature sensor is old (Sensatronics TempTrax E4 circa 2003) and uses non-standard html formatting so PowerShell refuses to parse it correctly. Hence the use of curl.exe.


Article Comments

Most likely, the issue is due to the fact your probe is a 64-bit operating system

PRTG Probe.exe is a 32-bit process; as such, when you run it it will look for curl.exe in C:\Windows\SysWOW64. Windows automatically redirects requests against system32 from 32-bit processes to SysWOW64, which contains the 32-bit versions of the executables they're interested in

To target processes in C:\Windows\system32 from a 32-bit program you need to target C:\Windows\sysnative\curl.exe. Otherwise, you can put a copy of curl.exe in SysWOW64, or just move it out of system32 entirely


Mar, 2018 - Permalink

Thank you for chipping in, lordmilko.

What might also work is putting curl.exe into the same folder as the script the sensor runs.

Kind regards,

Erhard


Mar, 2018 - Permalink

Copying curl.exe to C:\Windows\SysWOW64 did the trick. Thanks!


Mar, 2018 - Permalink