1
0
mirror of https://github.com/samba-team/samba.git synced 2025-01-26 10:04:02 +03:00

51 lines
1.1 KiB
Plaintext
Raw Normal View History

#!/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)
RECLOCKFILE=`ctdb -Y getreclock`
[ -z "$RECLOCKFILE" ] && {
# we are not using a reclock file
ctdb_counter_init "$RECLOCKCOUNT"
exit 0
}
ctdb_counter_incr "$RECLOCKCOUNT"
# try stat the reclock file as a background process
# so that we dont block in case the cluster filesystem is unavailable
(
stat $RECLOCKFILE && {
# 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