summaryrefslogtreecommitdiff
path: root/ctdb/config/events.d/01.reclock
blob: 1b6cbf09e440a2aa5eaada9f869bd2ddaaf70335 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
#!/bin/sh
# script to check accessibility to the reclock file on a node

. $CTDB_BASE/functions
loadconfig

case $cmd in 
    startup)
	ctdb_counter_init
	;;
    
    monitor)
	RECLOCKFILE=$(ctdb -Y getreclock)

	ctdb_counter_incr
	(ctdb_check_counter_limit 200 >/dev/null 2>&1) || {
	    echo "Reclock file $RECLOCKFILE\" can not be accessed. Shutting down."
	    df
	    sleep 1
	    ctdb shutdown
	}

	[ -z "$RECLOCKFILE" ] && {
	    # 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
	    }
	) >/dev/null 2>/dev/null &

	ctdb_check_counter_limit 3 quiet
	;;
    status)
	ctdb_checkstatus || exit $?
	;;
esac

exit 0