From 92f99867016a37691b8d83db845b9d5c03352af3 Mon Sep 17 00:00:00 2001 From: Vincent Composieux Date: Sat, 16 Jun 2018 17:53:02 +0200 Subject: [PATCH] Added processgraph function --- .functions | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/.functions b/.functions index d5d91d9..4113c1b 100644 --- a/.functions +++ b/.functions @@ -307,3 +307,9 @@ function pingraph { function wwwgraph { while true; do curl -s -o /dev/null -w '{"lookup": %{time_namelookup}, "connect": %{time_connect}, "appconnect": %{time_appconnect}, "pretransfer": %{time_pretransfer}, "redirect": %{time_redirect}, "starttransfer": %{time_starttransfer}, "total": %{time_total}}' $1 | sed -E 's/([0-9]),([0-9])/\1.\2/g'; sleep 1.5; done | jplot lookup+connect+appconnect+pretransfer+redirect+starttransfer+total } + +# Graph a process CPU and memory usage +# Usage: processgraph (Chrome, node, ...) +function processgraph { + while true; do ps aux | grep $1 | grep -v grep | awk '{ cpu += $3; mem += $4} END {print "{\"cpu\":"cpu",\"mem\":"mem"}"}' | sed -E 's/([0-9]),([0-9])/\1.\2/g'; sleep 0.2; done | jplot --steps 600 cpu+mem +}