Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I am looking to use monit to keep an eye on my site. I want it to treat it the site like an external user so am testing the url but it doesn't seem to follow redirects. The content check is being performed on the html of the redirect.

#request works:
if failed url content == "301"

#request fails
if failed url content == "actual content"

Finding out how to get the url check to follow 30X would be great.

share|improve this question
it kind of makes sense that it doesn't follow the redirect because, I don't see the monit http tool as a web client, its just there to search for strings. Like you wouldn't expect it to follow a javascript redirect, or a <meta> tag Refresh either. – Tom H Mar 20 '12 at 23:07
up vote 1 down vote accepted

Even though I dont see an option in the monit man page to make it follow redirects, I think that by testing the elements of the redirect explicitly. By first testing the redirect headers, and then the content of the target page, that you achieve the same sort of thing.

(Here is the response including a redirect from a request to sharelatex )

HTTP/1.1 301 Moved Permanently       <---- response code here
Server: nginx/0.7.65
Date: Tue, 20 Mar 2012 22:04:48 GMT
Content-Type: text/html
Content-Length: 185
Connection: keep-alive
Location:   <---- target location here

I would use something like the following;

check host with address
IF FAILED URL content == "301 Moved Permanently" 
    then alert
IF FAILED URL content == "Location:"
    then alert
IF FAILED URL content == "ShareLaTeX"         
    then alert

So breaking that down... These 2 lines, check that the HTTP:// page redirects correctly, and that it provides the correct target for the redirection.

check host with address
IF FAILED URL content == "301 Moved Permanently" then alert
IF FAILED URL content == "Location:" then alert  

Then test that you were redirected to the right place, and for some content....

then the following lines, effective follow the redirect explicitly and test the content of the HTTPS page at

 IF FAILED URL content == "ShareLaTeX" then alert   

I guess the first commands are going to make a bunch (2x) of requests per page, so it might be worth combining them somehow....

share|improve this answer
but isn't this checking the response code when what I am looking to check is the html content of where the 301 takes me? – henry.oswald Mar 20 '12 at 20:13
oh, sorry. I misunderstood your question. Ill take another looksee – Tom H Mar 20 '12 at 22:03
try that, ive updated the answer – Tom H Mar 22 '12 at 14:38

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.