Created
January 8, 2015 01:50
-
-
Save mallipeddi/24bd367932d6259fedcb to your computer and use it in GitHub Desktop.
go pprof helper script
This file contains hidden or 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 | |
BINARY=$1 | |
HOST=$2 | |
PORT=$3 | |
DURATION=$4 | |
echo "Forwarding port..." | |
ssh -t -t -L$PORT:localhost:$PORT $HOST & | |
SSH_PID=$! | |
sleep 3 | |
echo "Starting profile..." | |
curl "http://localhost:$PORT/<INSERT-PATH>/pprof/profile?seconds=$DURATION" > /tmp/profile | |
echo "Downloading profile..." | |
scp /tmp/profile default:/tmp/ | |
rm /tmp/profile | |
echo "Terminating ssh (pid=$SSH_PID)..." | |
kill -TERM $SSH_PID | |
echo "Processing profile..." | |
ssh default -- "go tool pprof --pdf /tmp/$BINARY /tmp/profile > /tmp/profile.pdf" | |
scp default:/tmp/profile.pdf /tmp/ | |
open /tmp/profile.pdf | |
echo "Done." |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment