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.
Add comment