Add a setting where CTDB will monitor and warn for low memory conditions.
authorRonnie Sahlberg <ronniesahlberg@gmail.com>
Thu, 22 Apr 2010 22:52:09 +0000 (08:52 +1000)
committerRonnie Sahlberg <ronniesahlberg@gmail.com>
Thu, 22 Apr 2010 23:08:38 +0000 (09:08 +1000)
    CTDB_MONITOR_FREE_MEMORY_WARN

BZ 59747

config/ctdb.sysconfig
config/events.d/00.ctdb

index a19dd0ee7cc39f43e3f6a47ffbe373d29cf5bbde..c94ce68b098831ce0e4a66d4e2a8cbd4f74557f2 100644 (file)
@@ -112,14 +112,19 @@ CTDB_RECOVERY_LOCK="/some/place/on/shared/storage"
 # defaults to tcp
 # CTDB_TRANSPORT="tcp"
 
-# When set, this variable makes ctdb monitor the amount of free memory
-# in the system (the second number in the buffers/cache output from free -m).
-# If the amount of free memory drops below this treshold the node will become
-# unhealthy and ctdb and all managed services will be shutdown.
+# These setting allow monitoring for low/out-out of memory conditions.
+#
+# If set, once available memory drops below CTDB_MONITOR_FREE_MEMORY_WARN
+# ctdb will start logging messages that memory is low, but will not
+# take any further action.
+#
+# If the amount of free memory drops below CTDB_MONITOR_FREE_MEMORY 
+# ctdb will fail all service over to a different node and finally shutdown.
 # Once this occurs, the administrator needs to find the reason for the OOM
 # situation, rectify it and restart ctdb with "service ctdb start"
 # The unit is MByte
-# CTDB_MONITOR_FREE_MEMORY=100
+# CTDB_MONITOR_FREE_MEMORY_WARN=100
+# CTDB_MONITOR_FREE_MEMORY=10
 
 # When set to yes, the CTDB node will start in DISABLED mode and not host
 # any public ip addresses. The administrator needs to explicitely enable
index 5255617a0a09ed19c18f036959f469e6d51067ad..bfebcd282e0d71899fe4dd5059fb8f1d03fcad91 100755 (executable)
@@ -44,6 +44,14 @@ case "$1" in
            fi
        }
 
+       # warn when we get low on memory
+       [ -z "$CTDB_MONITOR_FREE_MEMORY_WARN" ] || {
+               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_WARN"` != "0" ] && {
+                       echo "Running low on memory. Free:$FREE_MEM while CTDB treshold is $CTDB_MONITOR_FREE_MEMORY_WARN"
+               }
+       }
+
        # 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`