monit-general
[Top][All Lists]
Advanced

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

Re: [monit] How to Achieve "if x restarts within y cycles then exec ..."


From: Martin Pala
Subject: Re: [monit] How to Achieve "if x restarts within y cycles then exec ..."
Date: Fri, 27 Jun 2008 02:17:14 +0200
User-agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.8.1.13) Gecko/20080313 Iceape/1.1.9 (Debian-1.1.9-5)


Art Age Software wrote:
On Thu, Jun 26, 2008 at 4:27 PM, Martin Pala <address@hidden> wrote:

Art Age Software wrote:
I would like to be able to execute an arbitrary action after a
specified number of restart attempts have failed. It appears that the
only thing allowed in the "if x restarts within y cycles" clause is
the timeout command. Is that true?
Yes, that's true. We plan to add this feature, there is also patch from Alec
which implements it. I'll look on it and will try to integrate with upcoming
monit 5.0.

Thanks. Is there any work-around in the meantime? I was thinking of
creating a second "ghost" service that attempts to connect to mysql
each cycle and forces a failover if it cannot connect (but before the
other service times out). Something like:

---------------------
check process mysql1 with pidfile /var/run/mysqld/mysqld.pid
  mode manual
  every 2 cycles
  if failed unix "/var/lib/mysql/mysql.sock" then restart
  if failed host localhost port 3306 protocol mysql then restart
  if 5 restarts within 10 cycles then timeout

check host mysql2 with address localhost
  mode manual
  if failed port 3306 protocol mysql for 6 cycles then exec
"/usr/lib/heartbeat/hb_standby"
---------------------

What do you think? Or is there a better approach?

Yes, this could work. Optionally it could be possible to use the pidfile using similar approach:

--8<--
check process mysql with pidfile /var/run/mysqld/mysqld.pid
   mode manual
   every 2 cycles
   if failed unix "/var/lib/mysql/mysql.sock" then restart
   if failed host localhost port 3306 protocol mysql then restart
   if 5 restarts within 10 cycles then timeout

check file mysql_pidfile with path /var/run/mysqld/mysqld.pid
   mode manual
if changed timestamp for 5 cycles then exec "/usr/lib/heartbeat/hb_standby"
--8<--

On restart the script will change the timestamp of the pidfile => the second service check can trigger failover/standby based on it.

Martin






reply via email to

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