What is this?

This knowledgebase contains questions and answers about PRTG Network Monitor and network monitoring in general.

Learn more

PRTG Network Monitor

Intuitive to Use. Easy to manage.
More than 500,000 users rely on Paessler PRTG every day. Find out how you can reduce cost, increase QoS and ease planning, as well.

Free Download

Top Tags


View all Tags

HTTP Response code

Votes:

0

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.

exe-script-sensor http-sensor pe132

Created on Jul 7, 2015 7:20:01 PM



4 Replies

Votes:

0

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.

Created on Jul 8, 2015 8:31:28 AM by  Stephan Linke [Paessler Support]

Last change on Jul 8, 2015 8:33:02 AM by  Stephan Linke [Paessler Support]



Votes:

0

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.

Created on Jul 8, 2015 4:08:11 PM



Votes:

0

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.

Created on Jul 13, 2015 5:11:41 PM



Votes:

0

Glad I could help :)

Created on Jul 14, 2015 6:09:03 AM by  Stephan Linke [Paessler Support]




Disclaimer: The information in the Paessler Knowledge Base comes without warranty of any kind. Use at your own risk. Before applying any instructions please exercise proper system administrator housekeeping. You must make sure that a proper backup of all your data is available.