From 74f4b60513152a4806907f862d9c31511c961d1d Mon Sep 17 00:00:00 2001 From: Ronnie Sahlberg Date: Fri, 23 Apr 2010 08:52:09 +1000 Subject: [PATCH] Add a setting where CTDB will monitor and warn for low memory conditions. CTDB_MONITOR_FREE_MEMORY_WARN BZ 59747 --- config/ctdb.sysconfig | 15 ++++++++++----- config/events.d/00.ctdb | 8 ++++++++ 2 files changed, 18 insertions(+), 5 deletions(-) diff --git a/config/ctdb.sysconfig b/config/ctdb.sysconfig index bc310015..248e9444 100644 --- a/config/ctdb.sysconfig +++ b/config/ctdb.sysconfig @@ -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 diff --git a/config/events.d/00.ctdb b/config/events.d/00.ctdb index 9a9f3ef6..4d59edc9 100755 --- a/config/events.d/00.ctdb +++ b/config/events.d/00.ctdb @@ -38,6 +38,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` -- 2.34.1