[Top][All Lists]

[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 03:03:55 +0200
User-agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv: Gecko/20080313 Iceape/1.1.9 (Debian-1.1.9-5)

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

check process mysql with pidfile /var/run/mysqld/
  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/
  mode manual
  if changed timestamp for 5 cycles then exec

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

I like your approach better because it seems more reliable. With my
approach, I think it is possible for the mysql protocol checks to
succeed if the timing is just right (i.e. the check happens between
restart and crash).

With your approach, should the condition match exactly for both
checks? For example:

if 5 restarts within 10 cycles then timeout
if changed timestamp 5 times in 10 cycles then exec "hb_standby"

Will it then be guaranteed that if the restart/timeout condition
occurs, then the changed timestamp condition/action will also occur?
Or is there any potential for funny timing anomalies?

I have not tested it, i recommend using -v monit option to tune the solution ;) If you'll need help, let me know.


reply via email to

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