From 0505d06b12a04a5c5e813fb3f4799278f9e5b7eb Mon Sep 17 00:00:00 2001 From: Martin Schwenke Date: Mon, 16 Sep 2024 12:26:53 +1000 Subject: [PATCH] ctdb-scripts: Use ss -H option to simplify This option has been available since ~2018 and has been implemented in the stub since then. I guess we didn't use it because CentOS 7? Signed-off-by: Martin Schwenke Reviewed-by: Volker Lendecke Reviewed-by: Jerry Heyman --- ctdb/config/functions | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/ctdb/config/functions b/ctdb/config/functions index 85757a89744..6fad3479770 100755 --- a/ctdb/config/functions +++ b/ctdb/config/functions @@ -499,7 +499,7 @@ ctdb_check_unix_socket() return 1 fi - _out=$(ss -l -x "src ${_sockpath}" | tail -n +2) + _out=$(ss -l -xH "src ${_sockpath}") if [ -z "$_out" ]; then echo "ERROR: ${service_name} not listening on ${_sockpath}" return 1 @@ -602,7 +602,7 @@ get_tcp_connections_for_ip() { _ip="$1" - ss -tn state established "src [$_ip]" | awk 'NR > 1 {print $3, $4}' + ss -tnH state established "src [$_ip]" | awk '{print $3, $4}' } ######################################################## @@ -1205,10 +1205,10 @@ update_tickles() _my_connections="${tickledir}/${_port}.connections.$$" # Parentheses are needed around the filters for precedence but # the parentheses can't be empty! - ss -tn state established \ + ss -tnH state established \ "${_ip_filter:+( ${_ip_filter} )}" \ "${_port_filter:+( ${_port_filter} )}" | - awk 'NR > 1 {print $4, $3}' | + awk '{print $4, $3}' | sort >"$_my_connections" # Record our current tickles in a temporary file