[SCM] CTDB repository - branch 1.2 updated - ctdb-1.9.1-472-gd84c171

Ronnie Sahlberg sahlberg at samba.org
Tue Aug 16 18:39:54 MDT 2011


The branch, 1.2 has been updated
       via  d84c171a9ca18f9fe1f71a3fd329e77a012a1481 (commit)
       via  d1ab5d6cd17b71ebc737790f543820bb820b56fd (commit)
       via  eda0ce8f846d0a0c72a8883ee3e67b53fceafe37 (commit)
      from  041a00da8bf50e32f96d33661bf954901ab0f4b8 (commit)

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


- Log -----------------------------------------------------------------
commit d84c171a9ca18f9fe1f71a3fd329e77a012a1481
Author: Ronnie Sahlberg <ronniesahlberg at gmail.com>
Date:   Wed Aug 17 10:16:35 2011 +1000

    Add a new command 'ctdb checktcpport <port>'
    that tries to bind to the specified port on INADDR_ANY.
    
    This can be used for testing if a service is listening to that port or not.
    
    Errors are printed to stdout and the returned status code is either 0 : if we managed to bind to the port (in which case the service is NOT listening on that bort) or the value of errno that stopped us from binding to a port.
    
    errno for EADDRINUSE is 98 so a script using this command should check the status code against the value 98.
    If this command returns 98 it means the service is listening to the specified port.

commit d1ab5d6cd17b71ebc737790f543820bb820b56fd
Author: Ronnie Sahlberg <ronniesahlberg at gmail.com>
Date:   Wed Aug 17 10:00:28 2011 +1000

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

commit eda0ce8f846d0a0c72a8883ee3e67b53fceafe37
Author: Ronnie Sahlberg <ronniesahlberg at gmail.com>
Date:   Wed Aug 17 09:59:42 2011 +1000

    dont use a too big persistence timeout value

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

Summary of changes:
 Makefile.in                |    1 -
 config/events.d/40.fs_use  |   53 --------------------------------------------
 config/events.d/91.lvs     |    4 +-
 packaging/RPM/ctdb.spec.in |    1 -
 tools/ctdb.c               |   42 ++++++++++++++++++++++++++++++++++
 5 files changed, 44 insertions(+), 57 deletions(-)
 delete mode 100644 config/events.d/40.fs_use


Changeset truncated at 500 lines:

diff --git a/Makefile.in b/Makefile.in
index 3a4e7d9..5fa9e98 100755
--- a/Makefile.in
+++ b/Makefile.in
@@ -257,7 +257,6 @@ 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/events.d/40.fs_use b/config/events.d/40.fs_use
deleted file mode 100644
index 14d33fa..0000000
--- a/config/events.d/40.fs_use
+++ /dev/null
@@ -1,53 +0,0 @@
-#!/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/config/events.d/91.lvs b/config/events.d/91.lvs
index 0355ae9..beba98d 100755
--- a/config/events.d/91.lvs
+++ b/config/events.d/91.lvs
@@ -59,8 +59,8 @@ case "$1" in
 	ip addr del $CTDB_LVS_PUBLIC_IP/32 dev lo >/dev/null 2>/dev/null
 	ip addr add $CTDB_LVS_PUBLIC_IP/32 dev lo >/dev/null 2>/dev/null
 
-	ipvsadm -A -t $CTDB_LVS_PUBLIC_IP:0 -p 999999999 -s lc
-	ipvsadm -A -u $CTDB_LVS_PUBLIC_IP:0 -p 999999999 -s lc
+	ipvsadm -A -t $CTDB_LVS_PUBLIC_IP:0 -p 1999999 -s lc
+	ipvsadm -A -u $CTDB_LVS_PUBLIC_IP:0 -p 1999999 -s lc
 
 	# add all nodes (except ourselves) to the lvs config
 	ctdb lvs | egrep -v "^$PNN:" | sed -e "s/.*://" | while read IP; do
diff --git a/packaging/RPM/ctdb.spec.in b/packaging/RPM/ctdb.spec.in
index 0bd3be6..d536114 100644
--- a/packaging/RPM/ctdb.spec.in
+++ b/packaging/RPM/ctdb.spec.in
@@ -102,7 +102,6 @@ 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
diff --git a/tools/ctdb.c b/tools/ctdb.c
index ec9481e..6cada94 100644
--- a/tools/ctdb.c
+++ b/tools/ctdb.c
@@ -3296,6 +3296,47 @@ static int control_pstore(struct ctdb_context *ctdb, int argc, const char **argv
 	return 0;
 }
 
+/*
+  check if a service is bound to a port or not
+ */
+static int control_chktcpport(struct ctdb_context *ctdb, int argc, const char **argv)
+{
+	int s, ret;
+	unsigned v;
+	int port;
+        struct sockaddr_in sin;
+
+	if (argc != 1) {
+		printf("Use: ctdb chktcport <port>\n");
+		return EINVAL;
+	}
+
+	port = atoi(argv[0]);
+
+	s = socket(PF_INET, SOCK_STREAM, IPPROTO_TCP);
+	if (s == -1) {
+		printf("Failed to open local socket\n");
+		return errno;
+	}
+
+	v = fcntl(s, F_GETFL, 0);
+        fcntl(s, F_SETFL, v | O_NONBLOCK);
+
+	bzero(&sin, sizeof(sin));
+	sin.sin_family = PF_INET;
+	sin.sin_port   = htons(port);
+	ret = bind(s, (struct sockaddr *)&sin, sizeof(sin));
+	close(s);
+	if (ret == -1) {
+		printf("Failed to bind to local socket: %d %s\n", errno, strerror(errno));
+		return errno;
+	}
+
+	return 0;
+}
+
+
+
 static void log_handler(struct ctdb_context *ctdb, uint64_t srvid, 
 			     TDB_DATA data, void *private_data)
 {
@@ -4912,6 +4953,7 @@ static const struct {
 	{ "tfetch", 	     control_tfetch,      	false,	true,  "fetch a record from a [c]tdb-file", "<tdb-file> <key> [<file>]" },
 	{ "readkey", 	     control_readkey,      	true,	false,  "read the content off a database key", "<tdb-file> <key>" },
 	{ "writekey", 	     control_writekey,      	true,	false,  "write to a database key", "<tdb-file> <key> <value>" },
+	{ "checktcpport",    control_chktcpport,      	false,	true,  "check if a service is bound to a specific tcp port or not", "<port>" },
 };
 
 /*


-- 
CTDB repository


More information about the samba-cvs mailing list