Hi,

I have a bit of a complicated problem... or it is possible it is quite simple and I'm making it complicated.

The end result I am after is I want to set a sensor that can detect when it gets an http response code of 200 (good) and send a warning notification when it gets anything but the 200 response.

The steps I have taken so far:

First, I have a HTTP Advanced sensor set to go get a token from a url and store that token in a log file. This part works fine.

Next, I have made an EXE sensor with a powershell script:

$token = Get-Content 'C:\ProgramData\Paessler\PRTG Network Monitor\Logs (Sensors)\Result of Sensor 2109-A.txt' $url= "blahblah" <-- this accepts the $token value and makes a valid url that returns what I want it to. $request = [System.Net.WebRequest]::Create($url) $response = $request.GetResponse() [int]$response.StatusCode $response.Close()

This does get me an end result of 200 in powershell when the site is working, but when the sensor runs the script it tells me the following:

Response not wellformed: "(200 )" (code: PE132)

I have the value channel set to look at the prtg.standardlookups.http.statuscode in an attempt to have the 200 be accepted, but it doesn't seem to help.

I'm at a bit of a loss here because I'm not a programmer and my powershell experience is pretty limited as well. Any help would be greatly appreciated.

Thanks.


Article Comments

The script output has to look like this: value:message :)

I wrote a similar sensor last year - Get-HTTPResponseCode. A bit more sophisticated, but works just fine :) You might want to add your token code into the URL.


Jul, 2015 - Permalink

Hi Stephan,

Thanks for the reply.

The token that is generated by the process inside the HTTP Advanced Sensor changes after an hour which is why I had it as a separate sensor that feeds in to a log file that is consumed by the $token step in my code above.

I imagine the whole get token process could be worked in to the sensor you provided, but I don't know how I'd do that and I am fine with it as a distinct sensor.

I will give your sensor a try and see what result I get. I'll report back with progress / issues.

Thanks again.


Jul, 2015 - Permalink

Hi Stephan,

I've tested with your sensor and I'm happy to report that this has solved my issue. I now get a 200 result when the site is working and emails notifying when things are down / not working properly.

Thanks for your assistance.


Jul, 2015 - Permalink

Glad I could help :)


Jul, 2015 - Permalink