From: root Date: Tue, 8 Aug 2017 23:20:26 +0000 (+0100) Subject: etc/profile.d/sys.sh X-Git-Url: https://git.nbdom.net/?a=commitdiff_plain;h=e0fe3d8243dfafa71c876b3c6cab192bb9ed376e;p=nb.git etc/profile.d/sys.sh --- diff --git a/etc/profile.d/sys.sh b/etc/profile.d/sys.sh index e413f946..6f83c21c 100644 --- a/etc/profile.d/sys.sh +++ b/etc/profile.d/sys.sh @@ -35,13 +35,13 @@ sys_activity() { echo 'Top ips conns:' cat "$tmp.netstat" \ | tail -n +2 \ - | awk '$5~/^[0-9]/{gsub(/:.*/,"",$5);print $5}' \ + | awk '$5~/^[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+/{gsub(/:.*/,"",$5);print $5}' \ | sort \ | uniq -c \ | sed 's/^ *//' \ | sort -nr -k 1 \ | head \ - | sed 's/^/ /' \ + | awk '{ i++; sub(/^([0-9]+) +(.*?)$/,sprintf("%-15s %5d",$2,$1),$0); if (i % 2 == 0){ print $0 } else{ printf " "$0" | "} } END {if (i%2 != 0){print}}' \ ; echo