[SCM] CTDB repository - branch master updated - ctdb-1.10-336-g9f10c5d

Ronnie Sahlberg sahlberg at samba.org
Wed Aug 10 18:20:22 MDT 2011


The branch, master has been updated
       via  9f10c5d48a08ffb3417f880c801aed2aa2dc1355 (commit)
       via  2fd1babf8135ad5d53f3b25ba823d840ebc66460 (commit)
      from  8158077624eb763ba40c6a7b4b7faf3867b205d7 (commit)

http://gitweb.samba.org/?p=ctdb.git;a=shortlog;h=master


- Log -----------------------------------------------------------------
commit 9f10c5d48a08ffb3417f880c801aed2aa2dc1355
Author: Ronnie Sahlberg <ronniesahlberg at gmail.com>
Date:   Thu Aug 11 10:07:50 2011 +1000

    Add documentation for the new filesystem use monitoring

commit 2fd1babf8135ad5d53f3b25ba823d840ebc66460
Author: Ronnie Sahlberg <ronniesahlberg at gmail.com>
Date:   Thu Aug 11 10:00:53 2011 +1000

    Add new eventscript 40.fs_use that can be used to monitor file system use and flag a node unhealthy when they become full

-----------------------------------------------------------------------

Summary of changes:
 Makefile.in                |    1 +
 config/ctdb.sysconfig      |    9 +++++++
 config/events.d/40.fs_use  |   53 ++++++++++++++++++++++++++++++++++++++++++++
 packaging/RPM/ctdb.spec.in |    1 +
 4 files changed, 64 insertions(+), 0 deletions(-)
 create mode 100644 config/events.d/40.fs_use


Changeset truncated at 500 lines:

diff --git a/Makefile.in b/Makefile.in
index d53d3db..0cce22e 100755
--- a/Makefile.in
+++ b/Makefile.in
@@ -258,6 +258,7 @@ install: all
 	${INSTALLCMD} -m 644 config/events.d/20.multipathd $(DESTDIR)$(etcdir)/ctdb/events.d
 	${INSTALLCMD} -m 644 config/events.d/31.clamd $(DESTDIR)$(etcdir)/ctdb/events.d
 	${INSTALLCMD} -m 755 config/events.d/40.vsftpd $(DESTDIR)$(etcdir)/ctdb/events.d
+	${INSTALLCMD} -m 644 config/events.d/40.fs_use $(DESTDIR)$(etcdir)/ctdb/events.d
 	${INSTALLCMD} -m 755 config/events.d/41.httpd $(DESTDIR)$(etcdir)/ctdb/events.d
 	${INSTALLCMD} -m 755 config/events.d/50.samba $(DESTDIR)$(etcdir)/ctdb/events.d
 	${INSTALLCMD} -m 755 config/events.d/60.nfs $(DESTDIR)$(etcdir)/ctdb/events.d
diff --git a/config/ctdb.sysconfig b/config/ctdb.sysconfig
index 011593d..5115094 100644
--- a/config/ctdb.sysconfig
+++ b/config/ctdb.sysconfig
@@ -286,6 +286,15 @@ CTDB_DEBUGLEVEL=ERR
 # This parameter controls how many entries we allow for this in memory log
 # CTDB_LOG_RINGBUF_SIZE=500000
 
+# Monitor filesystem useage.
+# when set, and the 40.fs_use eventscript is enabled, this variable
+# allows to monitor the filesystem use and flag a node as unhealthy when
+# the filesystem becomes too full.
+# This is useful for example when /var grows too big.
+# Example: monitor both / and /var and make the node unhealthy when eitehr go
+# above 90%
+# CTDB_CHECK_FS_USE="/:90 /var:90"
+
 # 
 #
 # set any default tuning options for ctdb
diff --git a/config/events.d/40.fs_use b/config/events.d/40.fs_use
new file mode 100644
index 0000000..14d33fa
--- /dev/null
+++ b/config/events.d/40.fs_use
@@ -0,0 +1,53 @@
+#!/bin/sh
+# ctdb event script for checking local file system utilization
+
+. $CTDB_BASE/functions
+loadconfig
+
+case "$1" in 
+    monitor)
+        # check each specified fs to be checked
+        # config format is <fs_mount>:<fs_threshold>
+        for fs in $CTDB_CHECK_FS_USE
+        do
+            # parse fs_mount and fs_threshold
+            fs_config=(`echo $fs | tr ':' '\n'`)
+            fs_mount=${fs_config[0])}
+            fs_threshold=${fs_config[1])}
+
+            # check if given fs_mount is existing directory
+            if [ ! -d "$fs_mount" ]; then
+                echo "$0: Directory $fs_mount does not exist"
+                exit 1
+            fi
+
+            # check if given fs_threshold is number
+            if ! [[ "$fs_threshold" =~ ^[0-9]+$ ]] ; then
+                echo "$0: Threshold $fs_threshold is invalid number"
+                exit 1
+            fi
+
+            # get utilization of given fs from df
+            fs_usage=`df -k $fs_mount | grep % | awk {'print $5'} | sed 's/%//g' | tail -n 1`
+
+            # check if fs_usage is number
+            if ! [[ "$fs_usage" =~ ^[0-9]+$ ]] ; then
+                echo "$0: FS utilization $fs_usage is invalid number"
+                exit 1
+            fi
+
+            # check if fs_usage is higher than or equal to fs_threshold
+            if [[ "$fs_usage" -ge "$fs_threshold" ]] ; then
+                echo "ERROR: Utilization of $fs_mount ($fs_usage%) is higher than threshold ($fs_threshold%)"
+                exit 1
+            fi
+        done
+
+	;;
+
+    *)
+	ctdb_standard_event_handler "$@"
+	;;
+esac
+
+exit 0
diff --git a/packaging/RPM/ctdb.spec.in b/packaging/RPM/ctdb.spec.in
index c006b51..f618e76 100644
--- a/packaging/RPM/ctdb.spec.in
+++ b/packaging/RPM/ctdb.spec.in
@@ -102,6 +102,7 @@ rm -rf $RPM_BUILD_ROOT
 %{_sysconfdir}/ctdb/events.d/11.routing
 %{_sysconfdir}/ctdb/events.d/20.multipathd
 %{_sysconfdir}/ctdb/events.d/31.clamd
+%{_sysconfdir}/ctdb/events.d/40.fs_use
 %{_sysconfdir}/ctdb/events.d/40.vsftpd
 %{_sysconfdir}/ctdb/events.d/41.httpd
 %{_sysconfdir}/ctdb/events.d/50.samba


-- 
CTDB repository


More information about the samba-cvs mailing list