|
From: | Houssan A. Hijazi |
Subject: | Re: Monit http error status |
Date: | Thu, 1 Nov 2012 11:59:11 -0200 |
Hi,
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):
/usr/local/bin/myhttptest.sh:
--8<--
#!/bin/bash
exit `curl -sL -w "%{http_code}\\n" "http://mymachine" -o /dev/null`
--8<--
and then connect it to Monit like this:
--8<--
check process apache with pidfile /var/run/apache.pid
start program = ...
stop program = ...
check program myhttptest with path /usr/local/bin/myhttptest.sh
if status == 502 then restart
depends on apache
--8<--
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:
--8<--
if failed host cave.persia.ir 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
--8<--
Regards,
Martin
> --
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:
> https://lists.nongnu.org/mailman/listinfo/monit-general
--
To unsubscribe:
https://lists.nongnu.org/mailman/listinfo/monit-general
--
Houssan A. Hijazi
Analista de Sistemas
[Prev in Thread] | Current Thread | [Next in Thread] |