i was testing batch files using below script
@echo off del c:\test\d.txt c:\PsExec.exe \\server -u domain\username -p password netstat -n |find /c "IP/PORT" > c:\test\d.txt for /F %%i in (c:\test\d.txt) do set myRESULT=%%i echo RESULT IS %myRESULT% if %myRESULT%==0 (echo ":Server is Not Connected") REM Set PRTG Sensor to Warning by returning <1> Exit 1 else (echo ":Server is Connected")
if i run script normally i get proper output in txt file.
but if i use this batch scripts using PRTG EXE/Script sensor the output in txt file changed to 0 (output should be 1 or higher if server is connected)
need help...
Article Comments
Hi Erhard Thanks for your help..
now its showing as
Response not wellformed: "(Connecting to server... Starting PSEXESVC service on server... Connecting with PsExec service on server... Starting netstat on server... netstat exited on server with error code 0. )" (code: PE132)
@echo off del c:\test\d.txt c:\PsExec.exe \\server -u username -p password netstat -n |find /c "IP" > c:\test\d.txt for /F %%i in (c:\test\d.txt) do set myRESULT=%%i if %myRESULT%==0 echo %myRESULT%:Server is Not Connected REM Set PRTG Sensor to Warning by returning <1> Exit 1 else echo %myRESULT%:Server FIX Connected
thanks in advance.
Aug, 2017 - Permalink
its sorted now after re-framing my batch file thanks for your help Erhard.
@echo off del c:\test\d.txt c:\PsExec.exe server -u username -p password netstat -n |find /c "IP" > c:\test\d.txt for /F %%i in (c:\test\d.txt) do set myRESULT=%%i if %myRESULT%==1 echo %myRESULT%:Fidessa FIX is Connected if %myRESULT%==0 echo %myRESULT%:Fidessa FIX is Not Connected REM Set PRTG Sensor to Warning by returning <1> Exit 1
Aug, 2017 - Permalink
Hello there,
Please try this:
Does it work then?
Kind regards,
Erhard
Aug, 2017 - Permalink