2007-05-29 13:01:31 +10:00
#!/bin/sh
2007-06-01 20:54:26 +10:00
############################
# main event script for ctdb
2007-06-04 15:09:03 +10:00
#
# This script is called with one of the following sets of arguments
# startup : called when ctdb starts
# shutdown : called when ctdb shuts down
2007-06-04 23:54:46 +10:00
# takeip : called when an IP address is taken over
# releaseip : called when an IP address is released
# recovered : called when ctdb has finished a recovery event
2007-05-29 13:01:31 +10:00
2007-09-14 14:14:03 +10:00
. $CTDB_BASE/functions
2009-11-19 15:00:17 +11:00
loadconfig
2007-05-29 13:01:31 +10:00
2009-12-01 17:43:47 +11:00
case "$1" in
2007-05-30 12:27:58 +10:00
startup)
2007-06-04 15:09:03 +10:00
# make sure we have a blank state directory for the scripts to work with
2007-09-14 14:14:03 +10:00
/bin/rm -rf $CTDB_BASE/state
/bin/mkdir -p $CTDB_BASE/state
2007-06-04 20:05:31 +10:00
# set any tunables from the config file
set | grep ^CTDB_SET_ | cut -d_ -f3- |
while read v; do
varname=`echo $v | cut -d= -f1`
value=`echo $v | cut -d= -f2`
ctdb setvar $varname $value || exit 1
2008-01-16 22:06:44 +11:00
echo "Set $varname to $value"
2007-10-29 12:34:45 +11:00
done || exit 1
2007-05-30 12:27:58 +10:00
;;
2008-01-10 10:04:03 +11:00
monitor)
2008-02-21 13:29:28 +11:00
# monitor that we are not running out of memory
[ -z "$CTDB_MONITOR_FREE_MEMORY" ] || {
FREE_MEM=`free -m | grep "buffers/cache" | while read A B C D ;do /bin/echo -n $D ; done`
[ `expr "$FREE_MEM" "<" "$CTDB_MONITOR_FREE_MEMORY"` != "0" ] && {
echo "OOM. Free:$FREE_MEM while CTDB treshold is $CTDB_MONITOR_FREE_MEMORY"
ctdb disable
sleep 3
ctdb shutdown
}
}
2009-12-01 18:08:57 +11:00
;;
2009-12-01 17:43:47 +11:00
*)
ctdb_standard_event_handler "$@"
;;
2007-05-29 13:01:31 +10:00
esac
2007-06-01 20:54:26 +10:00
# all OK
exit 0