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