Created
June 14, 2018 11:46
-
-
Save zolotyh/765336188c0aff0f78bf78a7f66d5f99 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
# draw image and open chart for memory real | |
# and virtual usage | |
set e | |
FILE=measures.csv; | |
SCALE=1048576 | |
gnuplot <<- EOF | |
set parametric | |
set xlabel "Time" | |
set terminal png size 2560,1600 | |
set ylabel "Memory (gb)" | |
set title "Memory usage" | |
set datafile separator "," | |
set y2tics 1 | |
set ytics 1 | |
set my2tics 10 | |
set mytics 10 | |
set term png | |
set ytics nomirror | |
set output "${FILE}.png | |
const=3 | |
set grid ytics mytics | |
set key autotitle columnhead | |
plot '${FILE}' using 1:(\$2/$SCALE) with line, '${FILE}' using 1:(\$3/$SCALE) with line,'${FILE}' using 1:(\$4/100) with line | |
EOF | |
open "${FILE}.png" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
set -e | |
# some command in daemon mode | |
dart --use_compactor tool/grind.dart atomic-build-runner 2> error_report & | |
pid=$! | |
# If this script is killed, kill the `dart'. | |
trap "kill $pid 2> /dev/null" EXIT | |
(>&2 echo "NUMBER,VIRTUAL_MEMORY (kb),REAL_MEMORY (kb),CPU,SWAP") 2> ./measures.csv | |
# While process is running... | |
COUNTER=1 | |
while kill -0 $pid 2> /dev/null; do | |
VIRTUAL_MEMORY="$(ps -p $pid -o vsize=)"; | |
REAL_MEMORY="$(ps -p $pid -o rss=)"; | |
CPU="$(ps -p $pid -o %cpu=)"; | |
SWAP="$(ps -p $pid -o nswap=)"; | |
(>&2 echo $COUNTER","$VIRTUAL_MEMORY","$REAL_MEMORY","$CPU","$SWAP) 2>> ./measures.csv | |
COUNTER=$[$COUNTER +1] | |
sleep 1 | |
done | |
# Disable the trap on a normal exit. | |
trap - EXIT |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment