怎样通过pprof监控docker

来源:互联网 发布:网络火的歌曲有哪些 编辑:程序博客网 时间:2024/05/21 22:57

debug模式启动docker

$ /usr/bin/docker daemon -D -H tcp://0.0.0.0:2375 -H unix:///var/run/docker.sock

通过socat端口转发

$ socat -d -d TCP-LISTEN:8080,fork,bind=192.168.1.137 UNIX:/var/run/docker.sock

测试

[root@reg pprof]#  curl -s http://10.39.0.102:8080/debug/vars | jq .{  "cmdline": [    "/usr/bin/dockerd",    "-D"  ],  "memstats": {    "Alloc": 13847856,    "TotalAlloc": 71577968,    "Sys": 27052344,    "Lookups": 7829,    "Mallocs": 891300,    "Frees": 772846,    "HeapAlloc": 13847856,    "HeapSys": 18743296,    "HeapIdle": 1941504,    "HeapInuse": 16801792,    "HeapReleased": 1810432,    "HeapObjects": 118454,    "StackInuse": 1179648,    "StackSys": 1179648,    "MSpanInuse": 225280,    "MSpanSys": 262144,    "MCacheInuse": 4800,    "MCacheSys": 16384,    "BuckHashSys": 1460436,    "GCSys": 1374208,    "OtherSys": 4016228,    "NextGC": 25872553,    "LastGC": 1512984476111075800,    "PauseTotalNs": 29246607,    "PauseNs": [      317474,      1159328,      271770,  ...

获取命令行

$ curl -s http://10.39.0.102:8080/debug/pprof/cmdline/usr/bin/dockerd-D

通过客户端获取

$ go tool pprof http://10.39.0.102:8080/debug/pprof/profileFetching profile from http://10.39.0.102:8080/debug/pprof/profilePlease wait... (30s)Saved profile in /root/pprof/pprof.dockerd.10.39.0.102:8080.samples.cpu.001.pb.gzEntering interactive mode 

生成文件转成pdf

$  go tool pprof --pdf pprof.dockerd.10.39.0.102\:8080.samples.cpu.001.pb >call.pdf

get symbol

$ curl -s http://10.39.0.102:8080/debug/pprof/symbol  num_symbols: 1

如果你感兴趣,其它的信息都可以获取到

$ culr -s http://10.39.0.102:8080/debug/pprof/block$ curl -s http://10.39.0.102:8080/debug/pprof/heap$ curl -s http://10.39.0.102:8080/debug/pprof/goroutine$ curl -s http://10.39.0.102:8080/debug/pprof/threadcreate
原创粉丝点击