12
12
. $CTDB_BASE/functions
15
ctdb_setup_service_state_dir "ctdb"
15
18
update_config_from_tdb() {
16
# Pull optional ctdb configuration data out of config.tdb
17
PUBLICADDRESSESKEY='public_addresses:node#'`ctdb -t 1 xpnn|sed -e "s/.*://"`
18
rm -f $CTDB_VARDIR/state/public_addresses
19
ctdb pfetch config.tdb $PUBLICADDRESSESKEY $CTDB_VARDIR/state/public_addresses 2>/dev/null
20
[ "$?" = "0" ] && [ `stat --format="%s" /etc/ctdb/state/public_addresses` != "0" ] && [ ! -z "$CTDB_PUBLIC_ADDRESSES" ] && {
21
diff $CTDB_VARDIR/state/public_addresses $CTDB_PUBLIC_ADDRESSES >/dev/null 2>/dev/null
23
echo CTDB public address configuration had been updated.
24
echo Extracting new configuration from database.
25
diff $CTDB_VARDIR/state/public_addresses $CTDB_PUBLIC_ADDRESSES
26
cp $CTDB_VARDIR/state/public_addresses $CTDB_PUBLIC_ADDRESSES
28
service ctdb restart &
20
# Pull optional ctdb configuration data out of config.tdb
21
_key="public_addresses:node#$(ctdb -t 1 xpnn|sed -e 's/.*://')"
22
_t="$service_state_dir/public_addresses"
25
if ctdb pfetch config.tdb "$_key" "$_t" 2>/dev/null && \
26
[ -s "$_t" -a -n "$CTDB_PUBLIC_ADDRESSES"] && \
27
! cmp -s "$_t" "$CTDB_PUBLIC_ADDRESSES" ; then
29
echo "CTDB public address configuration has changed."
30
echo "Extracting new configuration from database."
31
diff "$_t" "$CTDB_PUBLIC_ADDRESSES"
32
cp "$_t" "$CTDB_PUBLIC_ADDRESSES"
33
echo "Restarting CTDB"
34
service ctdb restart &
35
42
# make sure we have a blank state directory for the scripts to work with
36
/bin/rm -rf $CTDB_VARDIR/state
37
/bin/mkdir -p $CTDB_VARDIR/state || {
43
rm -rf $CTDB_VARDIR/state
44
# Look at the pattern - this should not be -rf!!!
45
rm -f $ctdb_managed_dir/*
46
mkdir -p $CTDB_VARDIR/state || {
39
echo "/bin/mkdir -p $CTDB_VARDIR/state - failed - $ret"
48
echo "mkdir -p $CTDB_VARDIR/state - failed - $ret"
56
65
update_config_from_tdb &
68
# Inherit the debug level from ctdbd on each monitor run. If
69
# there's a more urgent need then override CTDB_CURRENT_DEBUGLEVEL
70
# using a file in $CTDB_BASE/rc.local.d/.
71
ctdb_set_current_debuglevel create
59
73
# We should never enter swap, so SwapTotal == SwapFree.
60
74
[ "$CTDB_CHECK_SWAP_IS_NOT_USED" = "yes" ] && {
61
75
if [ -n "`grep '^Swap\(Total\|Free\)' /proc/meminfo | uniq -s 10 -u`" ]; then
68
82
# warn when we get low on memory
69
83
[ -z "$CTDB_MONITOR_FREE_MEMORY_WARN" ] || {
70
FREE_MEM=`free -m | grep "buffers/cache" | while read A B C D ;do /bin/echo -n $D ; done`
84
FREE_MEM=`free -m | grep "buffers/cache" | while read A B C D ;do echo -n $D ; done`
71
85
[ `expr "$FREE_MEM" "<" "$CTDB_MONITOR_FREE_MEMORY_WARN"` != "0" ] && {
72
86
echo "Running low on memory. Free:$FREE_MEM while CTDB treshold is $CTDB_MONITOR_FREE_MEMORY_WARN"
76
90
# monitor that we are not running out of memory
77
91
[ -z "$CTDB_MONITOR_FREE_MEMORY" ] || {
78
FREE_MEM=`free -m | grep "buffers/cache" | while read A B C D ;do /bin/echo -n $D ; done`
92
FREE_MEM=`free -m | grep "buffers/cache" | while read A B C D ;do echo -n $D ; done`
79
93
[ `expr "$FREE_MEM" "<" "$CTDB_MONITOR_FREE_MEMORY"` != "0" ] && {
80
94
echo "OOM. Free:$FREE_MEM while CTDB treshold is $CTDB_MONITOR_FREE_MEMORY"