我期待用monit来关注我的网站。 我想它把它看作是一个外部用户的网站,所以我正在testing的url,但似乎并没有遵循redirect。 内容检查正在redirect的html上执行。
#request works: if failed url http://www.sharelatex.com/blog/posts/future.html content == "301" #request fails if failed url http://www.sharelatex.com/blog/posts/future.html content == "actual content"
找出如何获得url检查跟随30X将是伟大的。
即使我没有在monit手册页中看到一个选项使它跟随redirect,我认为通过显式testingredirect的元素。 通过首先testingredirect头,然后testing目标页面的内容,即可实现同样的事情。
(这是响应,包括从请求redirect到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: https://www.sharelatex.com/blog/posts/future.html <---- target location here
我会使用类似以下的东西;
check host www.sharelatex.com with address www.sharelatex.com IF FAILED URL http://www.sharelatex.com/blog/posts/future.html content == "301 Moved Permanently" then alert IF FAILED URL http://www.sharelatex.com/blog/posts/future.html content == "Location: https://www.sharelatex.com/blog/posts/future.html" then alert IF FAILED URL https://www.sharelatex.com/blog/posts/future.html content == "ShareLaTeX" then alert
因此,打破这一点…这两行,检查HTTP://页面是否正确redirect,并为redirect提供正确的目标。
check host www.sharelatex.com with address www.sharelatex.com IF FAILED URL http://www.sharelatex.com/blog/posts/future.html content == "301 Moved Permanently" then alert IF FAILED URL http://www.sharelatex.com/blog/posts/future.html content == "Location: https://www.sharelatex.com/blog/posts/future.html" then alert
然后testing你被redirect到正确的地方,并为一些内容….
那么下面的代码行会有效地遵循这个redirect,并且通过https://www.sharelatex.com/blog/posts/future.htmltestingHTTPS页面的内容。
IF FAILED URL https://www.sharelatex.com/blog/posts/future.html content == "ShareLaTeX" then alert
我想第一个命令将会使每页的请求(2x),所以它可能是值得组合它们….