From a9eec55c71f987d02538278aa8149e55f0e53409 Mon Sep 17 00:00:00 2001 From: Vincent Composieux Date: Sun, 17 Jun 2018 10:47:07 +0200 Subject: [PATCH] Added progressgraph new function --- .functions | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/.functions b/.functions index 1853d5b..4e8291e 100644 --- a/.functions +++ b/.functions @@ -309,7 +309,14 @@ function wwwgraph { } # Graph a process CPU and memory usage -# Usage: processgraph (Chrome, node, ...) +# 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 } + +# Graph a process CPU and memory usage over SSH +# Usage: sshprocessgraph (Chrome, node, ...) +function sshprocessgraph { + subcommand='ps aux | grep '"$2"' | grep -v grep | awk '\''{ cpu += $3; mem += $4} END {print "{\"cpu\":"cpu",\"mem\":"mem"}"}'\'' | sed -E "s/([0-9]),([0-9])/\1.\2/g"' + while true; do ssh $1 "$subcommand"; sleep 1; done | jplot --steps 400 cpu+mem +} \ No newline at end of file