1
0
mirror of https://github.com/samba-team/samba.git synced 2025-01-26 10:04:02 +03:00
Martin Schwenke 78b7043411 40.vsftpd monitor event only fails after 2 failures to connect to port 21.
Change the monitor event in 40.vsftpd so it only fails if there are 2
successive failures connecting to port 21.  This reduces the
likelihood of unhealthy nodes due to vsftpd being restarted for
reconfiguration due to node failover or system reconfiguration.

New eventscript functions ctdb_counter_init, ctdb_counter_incr,
ctdb_counter_limit.  These are used to count arbitrary things in
eventscripts, depending on the eventscript name and a tag that is
passed, and determine if a specified limit has been hit.  They're good
for counting failures!

These functions are used in 40.vsftpd and also in 01.reclock - the
latter used to do the counting without these functions.

Signed-off-by: Martin Schwenke <martin@meltin.net>

(This used to be ctdb commit cfe63636a163730ae9ad3554b78519b3c07d8896)
2009-09-30 21:05:16 +10:00

57 lines
1.2 KiB
Bash
Executable File

#!/bin/sh
# script to check accessibility to the reclock file on a node
. $CTDB_BASE/functions
loadconfig ctdb
cmd="$1"
shift
PATH=/usr/bin:/bin:/usr/sbin:/sbin:$PATH
# Count the number of intervals that have passed when we have tried to
# but failed to stat the reclock file. after third failure the node
# becomes unhealthy after the twentieth failure the node we shutdown
# ctdbd
RECLOCKCOUNT="fail-count"
case $cmd in
startup)
ctdb_counter_init "$RECLOCKCOUNT"
;;
monitor)
ctdb_counter_incr "$RECLOCKCOUNT"
ctdb_counter_limit "$RECLOCKCOUNT" 20 && {
echo "Reclock file can not be accessed. Shutting down."
sleep 1
ctdb shutdown
}
RECLOCKFILE=`ctdb -Y getreclock`
[ -z $RECLOCKFILE ] && {
# we are not using a reclock file
ctdb_counter_init "$RECLOCKCOUNT"
exit 0
}
# try stat the reclock file as a background process
# so that we dont block in case the cluster filesystem is unavailable
(
stat $RECLOCKFILE
[ "$?" -eq 0 ] && {
# we could stat the file, reset the counter
ctdb_counter_init "$RECLOCKCOUNT"
}
) >/dev/null 2>/dev/null &
ctdb_counter_limit "$RECLOCKCOUNT" 3 && {
echo "Reclock file can not be accessed. Mark node UNHEALTHY."
exit 1;
}
;;
esac
exit 0