Created
June 10, 2014 17:02
-
-
Save icholy/c37391b1773c73ea3315 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
#!/bin/bash | |
# | |
# Author: Ilia Choly <[email protected]> | |
# Year: 2014 | |
# | |
if [[ -z "$1" ]]; then | |
echo "usage: graph_memory.sh <pid>" | |
exit 1 | |
fi | |
_pid=$1 | |
_out_file=${_pid}.log | |
_gnuplot_file=${_pid}.gnuplot | |
echo -e " | |
set datafile separator \",\" | |
set terminal dumb | |
set title \"Memory Usage\" | |
set ylabel \"Bytes\" | |
set xlabel \"Date\" | |
set xdata time | |
set timefmt \"%s\" | |
set format x \"%m/%d\" | |
set key left top | |
set grid | |
plot \"${_out_file}\" using 1:2 title '${_pid}' | |
" > $_gnuplot_file | |
while true; do | |
_rss=$(ps ax -eo pid,rss | grep -e "^\s*$_pid" | awk '{ print $2 }') | |
_ts=$(date +"%s") | |
echo "$_ts, $_rss" >> $_out_file | |
clear | |
gnuplot $_gnuplot_file | |
sleep 10 | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment