The branch, master has been updated
       via  04cbb490c5a075080923fde58af7082572c55c43 (commit)
       via  82628e32c431d66b806399ffb9657c3a031f6428 (commit)
      from  a2c30d88348da47d1a733a16e4c7d83c3becb6df (commit)

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


- Log -----------------------------------------------------------------
commit 04cbb490c5a075080923fde58af7082572c55c43
Author: Ronnie Sahlberg <ronniesahlb...@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 82628e32c431d66b806399ffb9657c3a031f6428
Author: Ronnie Sahlberg <ronniesahlb...@gmail.com>
Date:   Wed Aug 17 09:59:42 2011 +1000

    dont use a too big persistence timeout value

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

Summary of changes:
 config/events.d/91.lvs |    4 ++--
 tools/ctdb.c           |   42 ++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 44 insertions(+), 2 deletions(-)


Changeset truncated at 500 lines:

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/tools/ctdb.c b/tools/ctdb.c
index 5618833..d760f6b 100644
--- a/tools/ctdb.c
+++ b/tools/ctdb.c
@@ -3348,6 +3348,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)
 {
@@ -4974,6 +5015,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

Reply via email to