PageRenderTime 45ms CodeModel.GetById 41ms app.highlight 2ms RepoModel.GetById 1ms app.codeStats 0ms

/ctdb/events.d/01.reclock

http://github.com/brinkman83/bashrc
Shell | 46 lines | 40 code | 4 blank | 2 comment | 1 complexity | c90844e94909aa7a7ca2bb9f9f5a5efe MD5 | raw file
 1#!/bin/sh
 2# script to check accessibility to the reclock file on a node
 3
 4. $CTDB_BASE/functions
 5loadconfig
 6
 7case "$1" in 
 8    startup)
 9	ctdb_counter_init
10	;;
11    
12    monitor)
13	RECLOCKFILE=$(ctdb -Y getreclock)
14
15	ctdb_counter_incr
16	(ctdb_check_counter_limit 200 >/dev/null 2>&1) || {
17	    echo "Reclock file $RECLOCKFILE\" can not be accessed. Shutting down."
18	    df
19	    sleep 1
20	    ctdb shutdown
21	}
22
23	[ -z "$RECLOCKFILE" ] && {
24	    # we are not using a reclock file
25	    ctdb_counter_init
26	    exit 0
27	}
28
29	# try stat the reclock file as a background process
30	# so that we dont block in case the cluster filesystem is unavailable
31	(
32	    stat $RECLOCKFILE && {
33		# we could stat the file, reset the counter
34		ctdb_counter_init
35	    }
36	) >/dev/null 2>/dev/null &
37
38	ctdb_check_counter_limit 3 quiet
39	;;
40
41    *)
42	ctdb_standard_event_handler "$@"
43	;;
44esac
45
46exit 0