From 57d9b8908c86b0053f16306976fe6bbcf664ed9d 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 | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/.functions b/.functions index d5d91d9..1853d5b 100644 --- a/.functions +++ b/.functions @@ -297,9 +297,9 @@ function transfer() { } # Graph ping between host and a given hostname -# Usage: ping -function pingraph { - while true; do echo '{"value": '`ping -c 1 $1 | awk -F"=| " 'NR==2 {print $10}'`'}'; sleep 0.5; done | jplot value +# Usage: pinggraph +function pinggraph { + while true; do echo '{"ping": '`ping -c 1 $1 | awk -F"=| " 'NR==2 {print $10}'`'}'; sleep 0.2; done | jplot --steps 500 ping } # Graph (using curl and jplot) website response times @@ -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 +}