summaryrefslogtreecommitdiff
path: root/pkg
diff options
context:
space:
mode:
authorTomás Touceda <chiiph@leap.se>2014-03-10 17:15:08 -0300
committerTomás Touceda <chiiph@leap.se>2014-03-10 17:15:08 -0300
commitabfaf49d82215e1b674123cd9a395fa5ac10bc7b (patch)
tree152b1b2604c507febb3725796fbe5c6883724106 /pkg
parentb762e09f6f20c07fccc66325079584213388102d (diff)
parent806fe6f8f6664da99f5405af5a831f0e48e3fe64 (diff)
Merge remote-tracking branch 'refs/remotes/kali/feature/graph-cpu-and-mem' into develop
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"