summaryrefslogtreecommitdiff
path: root/pkg
diff options
context:
space:
mode:
authorKali Kaneko <kali@leap.se>2014-03-05 15:28:08 -0400
committerKali Kaneko <kali@leap.se>2014-03-05 15:40:21 -0400
commit06c8d6f98768f173854585e3c9b36c4fa6bfe753 (patch)
tree980f425c4163ca02dd297834a9b1ec082c932f7e /pkg
parent496a4f8286e74daff080b52b02c49f130de03bc3 (diff)
script to graph cpu/mem usage. Related: #5259
Use as: RESOURCE_TIME=5 make resource_graph where RESOURCE_TIME are the minutes to run for.
Diffstat (limited to 'pkg')
-rwxr-xr-xpkg/scripts/monitor_resource.zsh26
1 files changed, 26 insertions, 0 deletions
diff --git a/pkg/scripts/monitor_resource.zsh b/pkg/scripts/monitor_resource.zsh
new file mode 100755
index 00000000..ac468e34
--- /dev/null
+++ b/pkg/scripts/monitor_resource.zsh
@@ -0,0 +1,26 @@
+#!/bin/zsh
+if (( ! $# )); then
+ echo "Usage: $0:t <PID> <minutes to monitor>" >&2
+ return 1;
+fi
+
+OUT="$1-usage.data"
+GRAPH="bitmask-resources.png"
+MAX=150
+let "ticks=$2*60/3"
+echo "cpu mem" >> $OUT
+for i in {1..$ticks}; do;
+ cpu=$(ps -p $1 -o pcpu | grep -v %)
+ mem=$(ps wuh -p $1 | awk '{print $4}')
+ echo "$cpu $mem" >> $OUT;
+ sleep 3;
+ echo $i / $ticks;
+done;
+
+gnuplot -e "set term dumb; \
+set key outside; set yrange [0:$MAX]; \
+plot for [col=1:2] '$OUT' using 0:col title columnheader s c"
+
+gnuplot -e "set term png; set output '$GRAPH'; \
+set key outside; set yrange [0:$MAX]; \
+plot for [col=1:2] '$OUT' using 0:col with lines title columnheader"