Last active
May 30, 2017 01:12
-
-
Save cliffano/55672a0862fada7ea1fbbfd64932096d to your computer and use it in GitHub Desktop.
chart a process
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
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" |
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
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