2010-05-04 13:56:55 +10:00
#!/bin/sh
# event script to integrate with gpfs cnfs
2013-01-03 15:26:12 +11:00
[ -n "$CTDB_BASE" ] || \
export CTDB_BASE=$(cd -P $(dirname "$0") ; dirname "$PWD")
2010-05-04 13:56:55 +10:00
. $CTDB_BASE/functions
loadconfig
2010-12-16 08:48:21 +11:00
ctdb_setup_service_state_dir "gpfs"
2010-05-24 09:51:52 +10:00
2010-05-04 13:56:55 +10:00
check_if_healthy() {
2010-12-16 08:48:21 +11:00
mkdir -p "$service_state_dir/fs"
2010-05-04 13:56:55 +10:00
2010-12-16 08:48:21 +11:00
[ -f "$service_state_dir/gpfsnoquorum" ] && {
2010-05-24 12:33:47 +10:00
logger No GPFS quorum. Node is UNHEALTHY
$CTDB_BASE/events.d/62.cnfs unhealthy "No GPFS quorum. Nodfe is UNHEALTHY."
exit 0
}
2010-05-04 13:56:55 +10:00
logger All required GPFS resources are available. CNFS part is healthy.
$CTDB_BASE/events.d/62.cnfs healthy
}
case "$1" in
startup)
check_if_healthy
;;
2010-05-24 12:33:47 +10:00
gpfsquorumreached)
2010-12-16 08:48:21 +11:00
rm -f "$service_state_dir/gpfsnoquorum"
2010-05-24 12:33:47 +10:00
logger "GPFS quorum has been reached."
check_if_healthy
;;
gpfsquorumloss)
2010-12-16 08:48:21 +11:00
touch "$service_state_dir/gpfsnoquorum"
2010-05-24 12:33:47 +10:00
logger "GPFS quorum has been lost."
$CTDB_BASE/events.d/62.cnfs unhealthy "GPFS quorum was lost! Marking node as UNHEALTHY."
;;
2010-05-04 13:56:55 +10:00
unhealthy)
# Mark the node as UNHEALTHY which means all public addresses
# will be migrated off the node.
shift
2013-08-21 14:34:49 +10:00
echo "$*" | ctdb_setstatus unhealthy -
2010-05-04 13:56:55 +10:00
# force a monitor event so we pick up immediately that this script
# will now fail and make the node unhealthy.
ctdb eventscript monitor
# Wait until we no longer serve any ip addresses at all
PNN=`ctdb pnn | cut -d: -f2`
2014-11-20 14:32:46 +11:00
while `ctdb -X ip | cut -d'|' -f3 | egrep "^$PNN$" >/dev/null`; do
2010-05-04 13:56:55 +10:00
sleep 1
done
;;
healthy)
# mark the node as healthy
ctdb_setstatus healthy
;;
monitor)
ctdb_checkstatus
exit $?
;;
*)
ctdb_standard_event_handler "$@"
;;
esac
exit 0