ctdb-scripts: Compact server-end TCP connection killing output
[samba.git] / ctdb / config / functions
index 9b0c3207533ca34ba3b2091cb2dd32966ee2f80b..2c630bd11bee8fb5e683eab3022cd1e4747ffaa2 100755 (executable)
@@ -97,26 +97,6 @@ loadconfig () {
 
 ##############################################################
 
-# CTDB_SCRIPT_DEBUGLEVEL can be overwritten by setting it in a
-# configuration file.
-debug ()
-{
-    if [ "${CTDB_SCRIPT_DEBUGLEVEL:-NOTICE}" = "DEBUG" ] ; then
-       # If there are arguments then echo them.  Otherwise expect to
-       # use stdin, which allows us to pass lots of debug using a
-       # here document.
-       if [ -n "$1" ] ; then
-           echo "DEBUG: $*"
-       else
-           sed -e 's@^@DEBUG: @'
-       fi
-    else
-       if [ -z "$1" ] ; then
-           cat >/dev/null
-       fi
-    fi
-}
-
 die ()
 {
     _msg="$1"
@@ -434,7 +414,6 @@ kill_tcp_connections ()
                139|445) __oneway=true ;;
            esac
 
-           echo "Killing TCP connection $_src $_dst"
            _connections="${_connections}${_nl}${_src} ${_dst}"
            if ! $__oneway ; then
                _connections="${_connections}${_nl}${_dst} ${_src}"
@@ -453,15 +432,22 @@ kill_tcp_connections ()
                return
        }
 
-       _remaining=$(get_tcp_connections_for_ip "$_ip" | wc -l)
-
-       if [ "$_remaining" -eq 0 ] ; then
-               echo "Killed $_killcount TCP connections to released IP $_ip"
-               return
+       _connections=$(get_tcp_connections_for_ip "$_ip")
+       if [ -z "$_connections" ] ; then
+               _remaining=0
+       else
+               _remaining=$(echo "$_connections" | wc -l)
        fi
 
-       _t="${_remaining}/${_killcount}"
-       echo "Failed to kill TCP connections for IP $_ip (${_t} remaining)"
+       _actually_killed=$((_killcount - _remaining))
+
+       _t="${_actually_killed}/${_killcount}"
+       echo "Killed ${_t} TCP connections to released IP $_ip"
+
+       if [ -n "$_connections" ] ; then
+               echo "Remaining connections:"
+               echo "$_connections" | sed -e 's|^|  |'
+       fi
     }
 }