summaryrefslogtreecommitdiff
path: root/pkg/tools/monitor_resource.zsh
diff options
context:
space:
mode:
authorKali Kaneko (leap communications) <kali@leap.se>2016-08-30 11:25:27 -0400
committerKali Kaneko (leap communications) <kali@leap.se>2016-08-30 11:25:35 -0400
commita9b4554156bac38cd3ca1162326ce9cf554f9b50 (patch)
tree21dacea8338235181b214fa233f93fdff3c0b022 /pkg/tools/monitor_resource.zsh
parent22eec36ff81ae2ec2b924087ed6253894b92278a (diff)
[pkg] add some relevant docs
Diffstat (limited to 'pkg/tools/monitor_resource.zsh')
-rwxr-xr-xpkg/tools/monitor_resource.zsh26
1 files changed, 26 insertions, 0 deletions
diff --git a/pkg/tools/monitor_resource.zsh b/pkg/tools/monitor_resource.zsh
new file mode 100755
index 00000000..ac468e34
--- /dev/null
+++ b/pkg/tools/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"