#!/bin/sh # event script to integrate with gpfs cnfs . $CTDB_BASE/functions loadconfig STATEDIR=$CTDB_VARDIR/state/gpfs check_if_healthy() { mkdir -p $STATEDIR/fs [ -f "$STATEDIR/gpfsnoquorum" ] && { logger No GPFS quorum. Node is UNHEALTHY $CTDB_BASE/events.d/62.cnfs unhealthy "No GPFS quorum. Nodfe is UNHEALTHY." exit 0 } logger All required GPFS resources are available. CNFS part is healthy. $CTDB_BASE/events.d/62.cnfs healthy } case "$1" in startup) mkdir -p $STATEDIR check_if_healthy ;; gpfsquorumreached) mkdir -p $STATEDIR rm -f "$STATEDIR/gpfsnoquorum" logger "GPFS quorum has been reached." check_if_healthy ;; gpfsquorumloss) mkdir -p $STATEDIR touch "$STATEDIR/gpfsnoquorum" logger "GPFS quorum has been lost." $CTDB_BASE/events.d/62.cnfs unhealthy "GPFS quorum was lost! Marking node as UNHEALTHY." ;; unhealthy) # Mark the node as UNHEALTHY which means all public addresses # will be migrated off the node. shift TMPFILE=/tmp/ctdb.cnfs.$$ echo "$*" > $TMPFILE ctdb_setstatus unhealthy $TMPFILE rm $TMPFILE # 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` while `ctdb -Y ip | cut -d: -f3 | egrep "^$PNN$" >/dev/null`; do sleep 1 done ;; healthy) # mark the node as healthy ctdb_setstatus healthy ;; monitor) ctdb_checkstatus exit $? ;; *) ctdb_standard_event_handler "$@" ;; esac exit 0