[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Monit http error status

From: Houssan A. Hijazi
Subject: Re: Monit http error status
Date: Thu, 1 Nov 2012 11:59:11 -0200


i created the file like this:

curl -o /dev/null --silent --head --write-out '%{http_code}\n'

it return the http response code.

in monit configuration i do:

check process nginx
  with pidfile /dh/nginx/servers/httpd-myserver/var/logs/ 
  start program = "/etc/init.d/nginx start"
   stop program = "/etc/init.d/nginx stop"
   if failed host port 80 protocol HTTP then restart #set your server IP that runs nginx
   if 5 restarts with 5 cycles then alert
check program webserverresponse with path /home/myhome/
    if content == "502" then restart
    depends on nginx

When i try  start monit:

$ sudo /etc/init.d/monit start
Starting daemon monitor: Syntax error:
/etc/monit/conf.d/nginx.conf:7: Error: syntax error 'webserverresponse'

Monit version: 1:5.1.1-1


2012/10/31 Martin Pala <address@hidden>

the default HTTP protocol test returns just failure if the HTTP code is error.

You can use the "check program" test with custom script and use curl/wget to get the http response code, for example (not tested):
exit `curl -sL -w "%{http_code}\\n" "http://mymachine" -o /dev/null`

and then connect it to Monit like this:
check process apache with pidfile /var/run/
    start program = ...
    stop program = ...

check program myhttptest with path /usr/local/bin/
    if status == 502 then restart
    depends on apache

Another option is to use the generic send/expect test to write simple HTTP check and test the 502 response - generic example from the monit manual:
 if failed host port 4040
    send "Open, Sesame!\r\n"
    expect "Please enter the cave\r\n"
    send "Shut, Sesame!\r\n"
    expect "See you later [A-Za-z ]+\r\n"
 then restart


On Oct 30, 2012, at 1:57 PM, Houssan A. Hijazi <address@hidden> wrote:

> Hi,
> i am on dreamhost using nginx with fastcgi, i need use monit to monitoring the nginx error, if error is 502 so restart.
> in my monit.log i have:
> HTTP error: Server returned status 502
> How i can see if host returned 502 error ?
> Thanks
> --
> To unsubscribe:

To unsubscribe:



Houssan A. Hijazi 

Analista de Sistemas /

reply via email to

[Prev in Thread] Current Thread [Next in Thread]