]> git.nbdom.net Git - nb.git/commitdiff
sys.sh
authorNicolas Boisselier <nicolas.boisselier@gmail.com>
Thu, 1 Dec 2016 10:59:12 +0000 (10:59 +0000)
committerNicolas Boisselier <nicolas.boisselier@gmail.com>
Thu, 1 Dec 2016 10:59:12 +0000 (10:59 +0000)
etc/profile.d/sys.sh

index 4b110943e845305c4c7426e7859abaaa1c996064..0bd3e3e8f198c37ec3a439b9e40fc32f398320df 100644 (file)
@@ -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"*
+}