diff options
| author | Martin Schwenke <martin@meltin.net> | 2011-08-17 14:02:45 +1000 |
|---|---|---|
| committer | Martin Schwenke <martin@meltin.net> | 2011-08-17 14:02:45 +1000 |
| commit | 6e7dbf05431c99e7022f025823bf28fc2b042f22 (patch) | |
| tree | 24ada71d58c13e01a7dfa40dddabd8ef0a2138c0 | |
| parent | 1374327f6e192a1c032c2383f255a9d653d76fa4 (diff) | |
| download | samba-6e7dbf05431c99e7022f025823bf28fc2b042f22.tar.gz samba-6e7dbf05431c99e7022f025823bf28fc2b042f22.tar.xz samba-6e7dbf05431c99e7022f025823bf28fc2b042f22.zip | |
Eventscripts - new default TCP port checker using "ctdb checktcpport"
New function ctdb_check_tcp_ports_ctdb(). This should be fast... and
is now the default checker. If it fails in an unexpected way we fall
back to the nmap and netstat checkers.
Signed-off-by: Martin Schwenke <martin@meltin.net>
(This used to be ctdb commit a1e16a707ce204817531a61455000361f972080a)
| -rwxr-xr-x | ctdb/config/functions | 29 |
1 files changed, 28 insertions, 1 deletions
diff --git a/ctdb/config/functions b/ctdb/config/functions index 737c8a7e7c..f65690359b 100755 --- a/ctdb/config/functions +++ b/ctdb/config/functions @@ -352,7 +352,7 @@ ctdb_check_tcp_ports() # If any of these defaults are unsupported then this variable can # be overridden in /etc/sysconfig/ctdb or via a file in # /etc/ctdb/rc.local.d/. - : ${CTDB_TCP_PORT_CHECKERS:=nmap netstat} + : ${CTDB_TCP_PORT_CHECKERS:=ctdb nmap netstat} for _c in $CTDB_TCP_PORT_CHECKERS ; do ctdb_check_tcp_ports_$_c "$@" @@ -459,6 +459,33 @@ $_nmap_out" return 0 } +# Use the new "ctdb checktcpport" command to check the port. +# This is very cheap. +ctdb_check_tcp_ports_ctdb () +{ + for _p ; do # process each function argument (port) + _cmd="ctdb checktcpport $_p" + _out=$($_cmd 2>&1) + case "$?" in + 0) + ctdb_check_tcp_ports_debug="\"$_cmd\" was able to bind to port" + return 1 + ;; + 98) + # Couldn't bind, something already listening, next port... + continue + ;; + *) + ctdb_check_tcp_ports_debug="$_cmd (exited with $?) with output: +$_out" + # assume not implemented + return 127 + esac + done + + return 0 +} + ###################################################### # check a unix socket # usage: ctdb_check_unix_socket SERVICE_NAME <socket_path> |
