1
0
mirror of https://github.com/samba-team/samba.git synced 2024-12-28 07:21:54 +03:00
samba-mirror/ctdb/config/events.d/20.multipathd
Martin Schwenke 609a1e5c77 Evenscripts: update 20.multipathd to use ctdb_setup_service_state_dir.
Signed-off-by: Martin Schwenke <martin@meltin.net>

(This used to be ctdb commit 797ca65bdd59b14325ffd32b4d4140e9b01dbe71)
2011-08-09 17:28:09 +10:00

95 lines
1.7 KiB
Bash
Executable File

#!/bin/sh
# ctdb event script for monitoring the multipath daemon
#
# Configure monitporing of multipath devices by listing the device serials
# in /etc/ctdb/multipathd :
# CTDB_MONITOR_MPDEVICES="device1 device2 ..."
#
. $CTDB_BASE/functions
service_name="multipathd"
loadconfig
[ -z "$CTDB_MONITOR_MPDEVICES" ] && {
exit 0
}
ctdb_setup_service_state_dir
MPFAILURE="$service_state_dir/failure"
multipathd_check_background()
{
for DEVICE in $CTDB_MONITOR_MPDEVICES; do
# check that we can see all devices
if [ -z "`multipath -ll $DEVICE`" ]; then
echo Device $DEVICE not known to multipathd
exit 1
fi
# check that all devices are active
if [ -z "`multipath -ll $DEVICE|grep prio|grep active`" ]; then
echo Device $DEVICE has no active paths
exit 1
fi
done
exit 0
}
multipathd_check()
{
# run the actual check in the background since the call to
# multipath may block.
(
multipathd_check_background &
pid="$!"
timeleft=10
while [ $timeleft -gt 0 ]; do
timeleft=$(($timeleft - 1))
# see if the process still exists
kill -0 $pid > /dev/null 2>&1 || {
# it doesn't exist, grab its exit status
wait $pid
[ $? = 0 ] || {
echo "20.multipathd: multipath background update exited with status $?"
touch $MPFAILURE
exit 1
}
rm $MPFAILURE 2>/dev/null
exit 0
}
sleep 1
done
echo "20.multipathd: Callout to multipath checks hung."
touch $MPFAILURE
exit 1
) &
if [ -f $MPFAILURE ]; then
return 1
else
return 0
fi
}
case "$1" in
monitor)
multipathd_check
[ "$?" = "0" ] || {
echo 20.multipathd: monitoring of multipathing failed
exit 1
}
exit 0
;;
*)
ctdb_standard_event_handler "$@"
;;
esac
exit 0