mirror of
https://github.com/samba-team/samba.git
synced 2025-01-26 10:04:02 +03:00
b27600253d
test -z really needs its argument to be quoted. Simplified a status test. Signed-off-by: Martin Schwenke <martin@meltin.net> (This used to be ctdb commit fe26da7780545b1ecc0a7da5bc1cf8beaeea94cc)
56 lines
1.2 KiB
Bash
Executable File
56 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 && {
|
|
# 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
|