2 ############################
3 # main event script for ctdb
5 # This script is called with one of the following sets of arguments
6 # startup : called when ctdb starts
7 # shutdown : called when ctdb shuts down
8 # takeip : called when an IP address is taken over
9 # releaseip : called when an IP address is released
10 # recovered : called when ctdb has finished a recovery event
12 .
$CTDB_BASE/functions
17 # make sure we have a blank state directory for the scripts to work with
18 /bin
/rm -rf $CTDB_BASE/state
19 /bin
/mkdir
-p $CTDB_BASE/state ||
{
21 echo "/bin/mkdir -p $CTDB_BASE/state - failed - $ret"
27 # set any tunables from the config file
28 set |
grep ^CTDB_SET_ | cut
-d_ -f3- |
30 varname
=`echo $v | cut -d= -f1`
31 value
=`echo $v | cut -d= -f2`
32 ctdb setvar
$varname $value ||
exit 1
33 echo "Set $varname to $value"
38 # We should never enter swap, so SwapTotal == SwapFree.
39 [ "$CTDB_CHECK_SWAP_IS_NOT_USED" = "yes" ] && {
40 if [ -n "`grep '^Swap\(Total\|Free\)' /proc/meminfo | uniq -s 10 -u`" ]; then
47 # monitor that we are not running out of memory
48 [ -z "$CTDB_MONITOR_FREE_MEMORY" ] ||
{
49 FREE_MEM
=`free -m | grep "buffers/cache" | while read A B C D ;do /bin/echo -n $D ; done`
50 [ `expr "$FREE_MEM" "<" "$CTDB_MONITOR_FREE_MEMORY"` != "0" ] && {
51 echo "OOM. Free:$FREE_MEM while CTDB treshold is $CTDB_MONITOR_FREE_MEMORY"
54 echo m
> /proc
/sysrq-trigger
63 ctdb_standard_event_handler
"$@"