1
0
mirror of https://github.com/ipfs/kubo.git synced 2025-08-06 19:44:01 +08:00

fix: allow profiling of remote node via https

License: MIT
Signed-off-by: Oli Evans <oli@tableflip.io>
This commit is contained in:
Oli Evans
2020-01-16 14:19:58 +00:00
parent 4eb380a58b
commit 982bc38a51

View File

@ -12,7 +12,7 @@
set -euo pipefail
IFS=$'\n\t'
HTTP_API="${1:-127.0.0.1:5001}"
SOURCE_URL="${1:-http://127.0.0.1:5001}"
tmpdir=$(mktemp -d)
export PPROF_TMPDIR="$tmpdir"
pushd "$tmpdir" > /dev/null
@ -22,27 +22,27 @@ if command -v ipfs > /dev/null 2>&1; then
fi
echo Collecting goroutine stacks
curl -s -o goroutines.stacks "http://$HTTP_API"'/debug/pprof/goroutine?debug=2'
curl -s -o goroutines.stacks "$SOURCE_URL"'/debug/pprof/goroutine?debug=2'
echo Collecting goroutine profile
go tool pprof -symbolize=remote -svg -output goroutine.svg "http://$HTTP_API/debug/pprof/goroutine"
go tool pprof -symbolize=remote -svg -output goroutine.svg "$SOURCE_URL/debug/pprof/goroutine"
echo Collecting heap profile
go tool pprof -symbolize=remote -svg -output heap.svg "http://$HTTP_API/debug/pprof/heap"
go tool pprof -symbolize=remote -svg -output heap.svg "$SOURCE_URL/debug/pprof/heap"
echo "Collecting cpu profile (~30s)"
go tool pprof -symbolize=remote -svg -output cpu.svg "http://$HTTP_API/debug/pprof/profile"
go tool pprof -symbolize=remote -svg -output cpu.svg "$SOURCE_URL/debug/pprof/profile"
echo "Enabling mutex profiling"
curl -X POST "http://$HTTP_API"'/debug/pprof-mutex/?fraction=4'
curl -X POST "$SOURCE_URL"'/debug/pprof-mutex/?fraction=4'
echo "Waiting for mutex data to be updated (30s)"
sleep 30
curl -s -o mutex.txt "http://$HTTP_API"'/debug/pprof/mutex?debug=2'
go tool pprof -symbolize=remote -svg -output mutex.svg "http://$HTTP_API/debug/pprof/mutex"
curl -s -o mutex.txt "$SOURCE_URL"'/debug/pprof/mutex?debug=2'
go tool pprof -symbolize=remote -svg -output mutex.svg "$SOURCE_URL/debug/pprof/mutex"
echo "Disabling mutex profiling"
curl -X POST "http://$HTTP_API"'/debug/pprof-mutex/?fraction=0'
curl -X POST "$SOURCE_URL"'/debug/pprof-mutex/?fraction=0'
OUTPUT_NAME=ipfs-profile-$(uname -n)-$(date +'%Y-%m-%dT%H:%M:%S%z').tar.gz
echo "Creating $OUTPUT_NAME"