|
From: | drich |
Subject: | Can monit run a script on service recovery? |
Date: | Wed, 30 Nov 2011 15:10:53 -0800 |
User-agent: | Roundcube Webmail/0.6 |
I'm in the middle of setting up monit for use in an anycast service high-availability setup, and have it working for taking the host out of anycast, but ran into an interesting problem -- is there a way to put the host back into the anycast rotation when things recover (i.e. someone fixes the down service and restarts whatever is down)?
For example, I can use the following for tomcat:
check process tomcat with pidfile /var/run/tomcat/tomcat.pid
start program = "/etc/init.d/tomcat start"
stop program = "/etc/init.d/tomcat stop"
if failed host localhost port 8080 protocol http
and request "/fcweb/" then restart
if 3 restarts within 5 cycles
then exec "/etc/init.d/ospfd stop"
group server
Stopping ospf will remove it from the cluster. Is there a way to restart ospfd when monit detects tomcat running again? I know I can put an else on the "if failed" statement, but I don't want to run the "ospfd start" script every time it starts back up. I only want to run it if it was down and then recovered.
The other thing that would be nice is a way to group the checks for restarting ospfd. For example:
check group server
if status failed
then exec "/etc/init.d/ospfd stop"
if status recovered
then exec "/etc/init.d/ospfd start"
or even if there was a way to have a check for multiple existing checks. Is there any way anyone can think of to implement something like that w/o running a separate script to check the monit status?
[Prev in Thread] | Current Thread | [Next in Thread] |