##############################################################
-# 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"
139|445) __oneway=true ;;
esac
- echo "Killing TCP connection $_src $_dst"
_connections="${_connections}${_nl}${_src} ${_dst}"
if ! $__oneway ; then
_connections="${_connections}${_nl}${_dst} ${_src}"
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
}
}