~ubuntu-branches/ubuntu/vivid/ctdb/vivid-proposed

« back to all changes in this revision

Viewing changes to config/events.d/00.ctdb

  • Committer: Package Import Robot
  • Author(s): Mathieu Parent
  • Date: 2011-11-06 15:18:59 UTC
  • mfrom: (1.2.14)
  • Revision ID: package-import@ubuntu.com-20111106151859-41lblk8ml4es7ra3
Tags: 1.11+git20111102-1
* New upstream release
  - removed 92-apache-service-enable.diff: integrated 
  - removed 99-fix-broken-readdir-test.diff: integrated
* d/rules, d/control, d/compat:
  - converted to dh (% target and dh_auto_*)
  - moved to compat level 9 (buildeps upgraded)
  - dh9 enabled hardening build flags
  - added hardening=+bindnow
  - dh9 enabled multiarch
    + Don't use /use/lib64 on ppc64 (Closes: #644907)
    + libctdb-dev is Multi-Arch: same
    + removed 10_no-lib64.diff: not needed with multiarch
* ctdb.init:
  - removed gettext support
  - synced with upstream

Show diffs side-by-side

added added

removed removed

Lines of Context:
12
12
. $CTDB_BASE/functions
13
13
loadconfig
14
14
 
 
15
ctdb_setup_service_state_dir "ctdb"
 
16
 
 
17
#
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
22
 
                [ $? = "0" ] || {
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
27
 
                        echo Restarting CTDB
28
 
                        service ctdb restart &
29
 
                }
30
 
        }
 
19
 
 
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"
 
23
    rm -f "$_t"
 
24
 
 
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
 
28
 
 
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
    fi
31
36
}
32
37
 
 
38
ctdb_check_args "$@"
 
39
 
33
40
case "$1" in 
34
41
     init)
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 || {
38
47
            ret=$?
39
 
            echo "/bin/mkdir -p $CTDB_VARDIR/state - failed - $ret"
 
48
            echo "mkdir -p $CTDB_VARDIR/state - failed - $ret"
40
49
            exit $ret
41
50
        }
42
51
        ;;
56
65
        update_config_from_tdb &
57
66
        ;;
58
67
    monitor)
 
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
 
72
 
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
67
81
 
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"
73
87
                }
75
89
 
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"
81
95
                        cat /proc/meminfo