New Question
 
 
PRTG Network Monitor

Intuitive to Use.
Easy to manage.

200.000 administrators have chosen PRTG to monitor their network. Find out how you can reduce cost, increase QoS and ease planning, as well.

Free PRTG
Download >>

 

What is this?

This knowledgebase contains questions and answers about PRTG Network Monitor and network monitoring in general. You are invited to get involved by asking and answering questions!

Learn more

 

Top Tags


View all Tags


HTTP Response code

Votes:

0

Your Vote:

Up

Down

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 by  Alan_C (0) 1



4 Replies

Votes:

0

Your Vote:

Up

Down

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

Your Vote:

Up

Down

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 by  Alan_C (0) 1



Votes:

0

Your Vote:

Up

Down

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 by  Alan_C (0) 1



Votes:

0

Your Vote:

Up

Down

Glad I could help :)

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



Please log in or register to enter your reply.


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.