summaryrefslogtreecommitdiffstats
path: root/ctdb/config/events.d/01.reclock
diff options
context:
space:
mode:
authorMartin Schwenke <martin@meltin.net>2009-11-19 15:00:17 +1100
committerMartin Schwenke <martin@meltin.net>2009-11-19 15:00:17 +1100
commitee513c1ba2292b86f1d3566a277570467e9d85c2 (patch)
tree47ddef66705f1eeaa15ce5278c8913fc6de8a7af /ctdb/config/events.d/01.reclock
parent73cb65bf1a7d3ff5a583965ab31a914485091fb5 (diff)
downloadsamba-ee513c1ba2292b86f1d3566a277570467e9d85c2.tar.gz
samba-ee513c1ba2292b86f1d3566a277570467e9d85c2.tar.xz
samba-ee513c1ba2292b86f1d3566a277570467e9d85c2.zip
More untested eventscript factorisation.
Signed-off-by: Martin Schwenke <martin@meltin.net> (This used to be ctdb commit ac655b0a65b32d809d47fec9821f7f31bb2fe2a7)
Diffstat (limited to 'ctdb/config/events.d/01.reclock')
-rwxr-xr-xctdb/config/events.d/01.reclock58
1 files changed, 23 insertions, 35 deletions
diff --git a/ctdb/config/events.d/01.reclock b/ctdb/config/events.d/01.reclock
index 281c0896b7..3d335507dd 100755
--- a/ctdb/config/events.d/01.reclock
+++ b/ctdb/config/events.d/01.reclock
@@ -2,55 +2,43 @@
# 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"
+loadconfig
case $cmd in
- startup)
- ctdb_counter_init "$RECLOCKCOUNT"
+ startup)
+ ctdb_counter_init
;;
-
- monitor)
- ctdb_counter_incr "$RECLOCKCOUNT"
- ctdb_counter_limit "$RECLOCKCOUNT" 200 && {
- echo "Reclock file \"$RECLOCKFILE\" can not be accessed. Shutting down."
- df
- sleep 1
- ctdb shutdown
+
+ monitor)
+ ctdb_counter_incr
+ (ctdb_counter_limit 200 >/dev/null 2>&1) || {
+ echo "Reclock file \"$RECLOCKFILE\" can not be accessed. Shutting down."
+ df
+ sleep 1
+ ctdb shutdown
}
- RECLOCKFILE=`ctdb -Y getreclock`
+ RECLOCKFILE=$(ctdb -Y getreclock)
[ -z "$RECLOCKFILE" ] && {
- # we are not using a reclock file
- ctdb_counter_init "$RECLOCKCOUNT"
- exit 0
+ # we are not using a reclock file
+ ctdb_counter_init
+ 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"
- }
+ stat $RECLOCKFILE && {
+ # we could stat the file, reset the counter
+ ctdb_counter_init
+ }
) >/dev/null 2>/dev/null &
- ctdb_counter_limit "$RECLOCKCOUNT" 3 && {
- echo "Reclock file \"$RECLOCKFILE\" can not be accessed. Mark node UNHEALTHY."
- df
- exit 1;
- }
+ ctdb_counter_limit 3
+ ;;
+ status)
+ ctdb_checkstatus || exit $?
;;
esac