I have used a vbs script I found in the Paessler KB which uses static entries in the script for a website and a return status code. The sensor works great like this. After I've altered the script to accept parameters the script still works and returns the same status when run on the server but the sensor errors out with "System Error: OK (Code: PEO22)"

sUrl = Wscript.Arguments(0)
sStatusToCheck = Wscript.Arguments(1)


If Wscript.Arguments.Count = 1 then
    sUrl = Wscript.Arguments(0)
End If

If Wscript.Arguments.Count = 2 then
    sUrl = Wscript.Arguments(0)
    sStatusToCheck = Wscript.Arguments(1)
End If

Set oXMLHTTP = CreateObject("MSXML2.ServerXMLHTTP.6.0")
oXMLHTTP.Open "GET", sUrl, False, " "," "
oXMLHTTP.Send

WScript.Echo oXMLHTTP.Status & ":" & oXMLHTTP.StatusText

If oXMLHTTP.Status = sStatusToCheck then
    WScript.Quit("0")
Else
    WScript.Quit("2")
End If

Article Comments

Hi,
please activate debugging for this sensor. Therefore switch to tab Settings of the sensor and set option Result Handling to "Write result to disk". This will create a file called Result of Sensor XXXX.txt, where XXXX represents the Sensor ID, to sub folder Logs (Sensors) of your PRTG Data Directory.
May you post the contents of the file?


Dec, 2013 - Permalink

The result is "200:OK". This is the same output I receive whether the variables are statically configure or are passed as parameters. So I am getting the same output but for some reason PRTG is giving me the error status if I pass the parameters.


Dec, 2013 - Permalink

Sean,
what error message do you get in the debug file when passing the parameters? May you implement some logging functionality in the script to generate a log file of what is happening? Have you tried including the parameters in apostrophes?
Best regards


Dec, 2013 - Permalink

This had to do with an string/integer mismatch. The error code parameter is passed as a string from PRTG so it must be converted to integer to compare it to the http status returned.


Dec, 2013 - Permalink