eventscripts: Remove TCP port checks other than the built-in CTDB one
authorMartin Schwenke <martin@meltin.net>
Thu, 17 Oct 2013 00:02:54 +0000 (11:02 +1100)
committerAmitay Isaacs <amitay@gmail.com>
Tue, 22 Oct 2013 03:34:04 +0000 (14:34 +1100)
"ctdb checktcpport" is no longer experimental so the other checkers
are no longer required.

Remove tests related to the removed checkers.

Signed-off-by: Martin Schwenke <martin@meltin.net>
config/functions
tests/eventscripts/50.samba.monitor.108.sh [deleted file]
tests/eventscripts/50.samba.monitor.109.sh [deleted file]
tests/eventscripts/50.samba.monitor.110.sh [deleted file]
tests/eventscripts/50.samba.monitor.111.sh [deleted file]

index 2a47b252236eeb0b098ecb86eb913ebe1f1b04be..68259b934a0f291774b1724f929dd9fbdde99213 100755 (executable)
@@ -485,7 +485,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:=ctdb nmap netstat}
+    : ${CTDB_TCP_PORT_CHECKERS:=ctdb}
 
     for _c in $CTDB_TCP_PORT_CHECKERS ; do
        ctdb_check_tcp_ports_$_c "$@"
@@ -525,74 +525,6 @@ EOF
     return 127
 }
 
-ctdb_check_tcp_ports_netstat ()
-{
-    _cmd='netstat -l -t -n'
-    _ns=$($_cmd 2>&1)
-    if [ $? -eq 127 ] ; then
-       # netstat probably not installed - unlikely?
-       ctdb_check_tcp_ports_debug="$_ns"
-       return 127
-    fi
-
-    for _p ; do  # process each function argument (port)
-       for _a in '0\.0\.0\.0' '::' ; do
-           _pat="[[:space:]]${_a}:${_p}[[:space:]]+[^[:space:]]+[[:space:]]+LISTEN"
-           if echo "$_ns" | grep -E -q "$_pat" ; then
-               # We matched the port, so process next port
-               continue 2
-           fi
-       done
-
-       # We didn't match the port, so flag an error.
-       ctdb_check_tcp_ports_debug="$_cmd shows this output:
-$_ns"
-       return 1
-    done
-
-    return 0
-}
-
-ctdb_check_tcp_ports_nmap ()
-{
-    # nmap wants a comma-separated list of ports
-    _ports=""
-    for _p ; do
-       _ports="${_ports}${_ports:+,}${_p}"
-    done
-
-    _cmd="nmap -n -oG - -PS 127.0.0.1 -p $_ports"
-
-    _nmap_out=$($_cmd 2>&1)
-    if [ $? -eq 127 ] ; then
-       # nmap probably not installed
-       ctdb_check_tcp_ports_debug="$_nmap_out"
-       return 127
-    fi
-
-    # get the port-related output
-    _port_info=$(echo "$_nmap_out" | sed -n -r -e 's@^.*Ports:[[:space:]]@@p')
-
-    for _p ; do
-       # looking for something like this:
-       #  445/open/tcp//microsoft-ds///
-       # possibly followed by a comma
-       _t="$_p/open/tcp//"
-       case "$_port_info" in
-           # The info we're after must be either at the beginning of
-           # the string or it must follow a space.
-            $_t*|*\ $_t*) : ;;
-           *)
-               # Nope, flag an error...
-               ctdb_check_tcp_ports_debug="$_cmd shows this output:
-$_nmap_out"
-               return 1
-       esac
-    done
-
-    return 0
-}
-
 # Use the new "ctdb checktcpport" command to check the port.
 # This is very cheap.
 ctdb_check_tcp_ports_ctdb ()
diff --git a/tests/eventscripts/50.samba.monitor.108.sh b/tests/eventscripts/50.samba.monitor.108.sh
deleted file mode 100755 (executable)
index fcd5d27..0000000
+++ /dev/null
@@ -1,15 +0,0 @@
-#!/bin/sh
-
-. "${TEST_SCRIPTS_DIR}/unit.sh"
-
-define_test "port 139 down, ctdb checktcpport not implemented"
-
-# TODO: create nmap stub
-export CTDB_NOT_IMPLEMENTED="checktcpport"
-
-setup_samba
-tcp_port_down 139
-
-required_result 1 "ERROR: samba tcp port 139 is not responding"
-
-simple_test
diff --git a/tests/eventscripts/50.samba.monitor.109.sh b/tests/eventscripts/50.samba.monitor.109.sh
deleted file mode 100755 (executable)
index 0104fd9..0000000
+++ /dev/null
@@ -1,29 +0,0 @@
-#!/bin/sh
-
-. "${TEST_SCRIPTS_DIR}/unit.sh"
-
-define_test "port 139 down, ctdb checktcpport not implemented, debug"
-
-ctdb_not_implemented "checktcpport"
-
-export CTDB_SCRIPT_DEBUGLEVEL=4
-
-setup_nmap_output_filter
-
-setup_samba
-tcp_port_down 139
-
-required_result 1 <<EOF
-DEBUG: ctdb_check_ports - checker ctdb not implemented
-DEBUG: output from checker was:
-DEBUG: ctdb checktcpport 445 (exited with 1) with output:
-$ctdb_not_implemented
-ERROR: samba tcp port 139 is not responding
-DEBUG: nmap -n -oG - -PS 127.0.0.1 -p 445,139 shows this output:
-DEBUG: # Nmap 5.21 scan initiated DATE as: nmap -n -oG - -PS 127.0.0.1 -p 445,139
-DEBUG: Host: 127.0.0.1 ()      Status: Up
-DEBUG: Host: 127.0.0.1 ()      Ports: 445/open/tcp//microsoft-ds///, 139/closed/tcp//netbios-ssn///
-DEBUG: # Nmap done at DATE -- 1 IP address (1 host up) scanned in 0.04 seconds
-EOF
-
-simple_test
diff --git a/tests/eventscripts/50.samba.monitor.110.sh b/tests/eventscripts/50.samba.monitor.110.sh
deleted file mode 100755 (executable)
index 4697e54..0000000
+++ /dev/null
@@ -1,32 +0,0 @@
-#!/bin/sh
-
-. "${TEST_SCRIPTS_DIR}/unit.sh"
-
-define_test "port 139 down, ctdb checktcpport/nmap not implemented, debug"
-
-ctdb_not_implemented "checktcpport"
-export FAKE_NMAP_NOT_FOUND="yes"
-
-export CTDB_SCRIPT_DEBUGLEVEL=4
-
-setup_nmap_output_filter
-
-setup_samba
-tcp_port_down 139
-
-required_result 1 <<EOF
-DEBUG: ctdb_check_ports - checker ctdb not implemented
-DEBUG: output from checker was:
-DEBUG: ctdb checktcpport 445 (exited with 1) with output:
-$ctdb_not_implemented
-DEBUG: ctdb_check_ports - checker nmap not implemented
-DEBUG: output from checker was:
-DEBUG: sh: nmap: command not found
-ERROR: samba tcp port 139 is not responding
-DEBUG: netstat -l -t -n shows this output:
-DEBUG: Active Internet connections (servers only)
-DEBUG: Proto Recv-Q Send-Q Local Address           Foreign Address         State
-DEBUG: tcp        0      0 0.0.0.0:445             0.0.0.0:*               LISTEN
-EOF
-
-simple_test
diff --git a/tests/eventscripts/50.samba.monitor.111.sh b/tests/eventscripts/50.samba.monitor.111.sh
deleted file mode 100755 (executable)
index c7f924c..0000000
+++ /dev/null
@@ -1,20 +0,0 @@
-#!/bin/sh
-
-. "${TEST_SCRIPTS_DIR}/unit.sh"
-
-define_test "port 139 down, ctdb checktcpport/nmap/netstat not implemented"
-
-ctdb_not_implemented "checktcpport"
-export FAKE_NMAP_NOT_FOUND="yes"
-export FAKE_NETSTAT_NOT_FOUND="yes"
-
-setup_nmap_output_filter
-
-setup_samba
-tcp_port_down 139
-
-required_result 127 <<EOF
-INTERNAL ERROR: ctdb_check_ports - no working checkers in CTDB_TCP_PORT_CHECKERS="ctdb nmap netstat"
-EOF
-
-simple_test