From: Nicolas Boisselier Date: Thu, 1 Dec 2016 10:59:12 +0000 (+0000) Subject: sys.sh X-Git-Url: https://git.nbdom.net/?a=commitdiff_plain;h=6198f5cd5c8b85d67ef663b34012c81f6e1402f3;p=nb.git sys.sh --- diff --git a/etc/profile.d/sys.sh b/etc/profile.d/sys.sh index 4b110943..0bd3e3e8 100644 --- a/etc/profile.d/sys.sh +++ b/etc/profile.d/sys.sh @@ -1,3 +1,18 @@ sys_is_vm() { grep -q ^flags.*\ hypervisor /proc/cpuinfo && echo "This machine is a VM" } + +sys_watch() { + local tmp=/tmp/ + [ -d /dev/shm/ ] && tmp=/dev/shm/ + tmp="$tmp/$FUNCNAME.$$" + netstat -autpn > $tmp.netstat + + echo 'IOPS:' + iostat -c -m -d -x `df -hT -x tmpfs|perl -ane 'm:^/: and print $F[0]."\n"'` + + echo 'Top ip activity:' + cat "$tmp.netstat" | tail -n +2 | awk '$5~/^[0-9]/{gsub(/:.*/,"",$5);print $5}' | sort | uniq -c| sed 's/^ *//'|sort -nr -k 1 |head + + rm -rf "$tmp"* +}