From 2a6eb375d63e3b3fbca3c5b483074c28d2ee26dd Mon Sep 17 00:00:00 2001 From: root Date: Wed, 9 Aug 2017 00:00:31 +0100 Subject: [PATCH] etc/profile.d/sys.sh --- etc/profile.d/sys.sh | 21 ++++++++++++++++----- 1 file changed, 16 insertions(+), 5 deletions(-) diff --git a/etc/profile.d/sys.sh b/etc/profile.d/sys.sh index 98717123..e413f946 100644 --- a/etc/profile.d/sys.sh +++ b/etc/profile.d/sys.sh @@ -32,8 +32,17 @@ sys_activity() { free -hm | sed 's/^/ /' echo - echo 'Top ips:' - cat "$tmp.netstat" | tail -n +2 | awk '$5~/^[0-9]/{gsub(/:.*/,"",$5);print $5}' | sort | uniq -c| sed 's/^ *//'|sort -nr -k 1 |head | sed 's/^/ /' + echo 'Top ips conns:' + cat "$tmp.netstat" \ + | tail -n +2 \ + | awk '$5~/^[0-9]/{gsub(/:.*/,"",$5);print $5}' \ + | sort \ + | uniq -c \ + | sed 's/^ *//' \ + | sort -nr -k 1 \ + | head \ + | sed 's/^/ /' \ + ; echo echo 'dmesg:' @@ -59,8 +68,10 @@ sys_watch() { local opt="$@" [ -z "$opt" ] && opt="-d" - export -f sys_activity - #watch --no-title $opt sys_activity - watch --no-title $opt bash -c "sys_activity" + shopt -s expand_aliases; + export -f $(typeset -f | awk '/^[a-z]+[a-zA-Z0-9_]+ \(\)/{print $1}') + watch --no-title $opt sys_activity +# NB 08.08.17 export -f sys_activity +# NB 08.08.17 watch --no-title $opt bash -c "sys_activity" } -- 2.47.3