2 # ctdb event script for monitoring the multipath daemon
4 # Configure monitporing of multipath devices by listing the device serials
5 # in /etc/ctdb/multipathd :
6 # CTDB_MONITOR_MPDEVICES="device1 device2 ..."
9 [ -n "$CTDB_BASE" ] || \
10 export CTDB_BASE
=$
(cd -P $
(dirname "$0") ; dirname "$PWD")
12 .
$CTDB_BASE/functions
14 service_name
="multipathd"
18 [ -n "$CTDB_MONITOR_MPDEVICES" ] ||
exit 0
20 ctdb_setup_service_state_dir
22 multipath_fail
="${service_state_dir}/fail"
24 multipathd_check_background
()
26 for _device
in $CTDB_MONITOR_MPDEVICES; do
27 # Check multipath knows about the device
28 _out
=$
(multipath
-ll "$_device")
29 if [ -z "$_out" ] ; then
30 echo "device \"${_device}\" not known to multipathd" >"$multipath_fail"
34 # Check for at least 1 active path
35 if ! echo "$_out" |
grep 'prio=.* status=active' >/dev
/null
2>&1 ; then
36 echo "multipath device \"${_device}\" has no active paths" >"$multipath_fail"
45 # Run the actual check in the background since the call to
47 multipathd_check_background
</dev
/null
>/dev
/null
2>&1 &
51 while [ $_timeleft -gt 0 ]; do
52 _timeleft
=$
(($_timeleft - 1))
54 # see if the process still exists
55 kill -0 $_pid >/dev
/null
2>&1 ||
{
61 rm -f "$multipath_fail"
68 echo "ERROR: callout to multipath checks hung"
69 # If hung then this probably won't work, but worth trying...
70 kill -9 $_pid >/dev
/null
2>&1
76 multipathd_check || die
"multipath monitoring failed"
80 ctdb_standard_event_handler
"$@"