Skip to content

Instantly share code, notes, and snippets.

@cliffano
Last active May 30, 2017 01:12
Show Gist options
  • Save cliffano/55672a0862fada7ea1fbbfd64932096d to your computer and use it in GitHub Desktop.
Save cliffano/55672a0862fada7ea1fbbfd64932096d to your computer and use it in GitHub Desktop.
chart a process
set term png small size 800,600
set output "command-ps-graph.png"
set ylabel "%CPU"
set y2label "MEM"
set ytics nomirror
set y2tics nomirror in
set yrange [0:*]
set y2range [0:*]
plot "/tmp/command-ps.log" using 3 with lines axes x1y1 title "%CPU", \
"/tmp/command-ps.log" using 2 with lines axes x1y2 title "MEM"
keyword=${1}
if [ "$#" -ne 1 ]; then
echo "Usage: command-ps.sh <keyword>"
exit 1
fi
rm -f /tmp/command-ps.log
while true; do
ps -o command=,rss=,%cpu= | grep "$keyword" | grep -v grep >> /tmp/command-ps.log
sleep 0.5
done
# CTRL+C to finish collecting stat
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment