离线环境来从现场获取docker的pprof信息步骤 获取go的镜像 ```shell while read img; do docker run --rm --entrypoint go $img version 2>/dev/null | grep -qw version && { echo $img;break; }; done < <(docker images --format '{{.Repository}}:{{.Tag}}') ``` 转发docker的sock成tcp ```shell socat -d -d TCP-LISTEN:8081,fork,bind=0.0.0.0 UNIX:/var/run/docker.sock socat -d -d TCP-LISTEN:18081,fork,bind=0.0.0.0 TCP4:1.1.1.1:30000 ``` 镜像起容器获取pprof文件 ```shell go tool pprof http://1x.xxx.45.162:8080/debug/pprof/goroutine # 或者 curl -s http://1x.xxx.45.162:8080/debug/pprof/goroutine > test.goroutine curl -s http://1x.xxx.45.162:8080/debug/pprof/heap # 然后把`test.goroutine`拿回来转换成pdf yum install -y graphviz go tool pprof --pdf test.goroutine > goroutine.pdf go tool pprof -http=0.0.0.0:8080 test.goroutine ``` other: - https://segmentfault.com/a/1190000016412013 curl http://192.168.111.2:8001/debug/pprof/ ​ # output:
CountProfile
4524allocs
0block
0cmdline
1947goroutine
4524heap
0mutex
0profile
10threadcreate
0trace