github.com/cockroachdb/cockroach@v20.2.0-alpha.1+incompatible/scripts/pprof (about) 1 #!/usr/bin/env bash 2 # 3 # This script wraps "go tool pprof" (and stunnel) to work better with 4 # HTTPS servers using untrusted certificates (like cockroachdb). 5 # 6 # Go 1.8 introduced the "https+insecure" option to ignore certificate 7 # validation errors, but it did not extend to the symbolizer 8 # (https://github.com/google/pprof/issues/94). In go 1.9, this script 9 # should be obsolete. 10 11 set -euo pipefail 12 13 server=$1 14 if [ -z "${server}" ]; then 15 echo "host:port not specified, run with: $0 host:port [profile_type]" 16 exit 1 17 fi 18 19 profile_type=${2-profile} 20 21 port=8089 22 23 pidfile=$(mktemp /tmp/pprof.XXXXXX) 24 stunnel -fd 0 <<EOF 25 pid=${pidfile} 26 [http] 27 client = yes 28 accept = 127.0.0.1:${port} 29 connect = $1 30 EOF 31 32 cleanup() { 33 kill "$(cat ${pidfile})" 34 # stunnel cleans up its own pidfile on exit 35 } 36 37 trap cleanup EXIT 38 39 go tool pprof "http://127.0.0.1:${port}/debug/pprof/${profile_type}"