Created
November 30, 2016 15:55
-
-
Save ttacon/c69ae8d90493132ce63e716ad3be066a to your computer and use it in GitHub Desktop.
perf.sh - Bash template for building flamegraphs of node process on remote instances
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 | |
# | |
# See: https://mixmax.com/blog/determining-why-that-server-is-on-fire for usage. | |
# | |
########### | |
echo "installing perf..." | |
sudo yum install -y perf | |
echo "fixing file perms..." | |
sudo chown root /tmp/perf-*.map | |
DUR=DURATION # this is replaced by profile.sh | |
PIDS=$(PID_MATCHER) # this is replaced by profile.sh | |
echo "collecting info for $DUR seconds..." | |
echo "collecting info on $PIDS..." | |
sudo perf record -F 99 -o perf.data -p $PIDS -g -- sleep $DUR | |
echo "running perf..." | |
sudo perf script -i perf.data > out.nodestacks01 | |
echo "cloning flamegraph..." | |
git clone --depth 1 http://github.com/brendangregg/FlameGraph | |
cd FlameGraph | |
echo "creating flamegraph..." | |
./stackcollapse-perf.pl < ../out.nodestacks01 | ./flamegraph.pl > ../flame.svg |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment