diff options
author | Kali Kaneko (leap communications) <kali@leap.se> | 2016-08-30 11:25:27 -0400 |
---|---|---|
committer | Kali Kaneko (leap communications) <kali@leap.se> | 2016-08-30 11:25:35 -0400 |
commit | a9b4554156bac38cd3ca1162326ce9cf554f9b50 (patch) | |
tree | 21dacea8338235181b214fa233f93fdff3c0b022 /pkg/tools/monitor_resource.zsh | |
parent | 22eec36ff81ae2ec2b924087ed6253894b92278a (diff) |
[pkg] add some relevant docs
Diffstat (limited to 'pkg/tools/monitor_resource.zsh')
-rwxr-xr-x | pkg/tools/monitor_resource.zsh | 26 |
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" |