Forked from Jimmy-Xu/pprof-in-docker-daemon.md
Created
January 6, 2021 03:09
Revisions
-
Jimmy-Xu revised this gist
Jan 21, 2017 . 1 changed file with 14 additions and 11 deletions.There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -16,17 +16,20 @@ > source file: [docker\api\server\profiler.go](https://github.com/docker/docker/blob/master/api/server/profiler.go) ```go const debugPathPrefix = "/debug/" func profilerSetup(mainRouter *mux.Router) { var r = mainRouter.PathPrefix(debugPathPrefix).Subrouter() r.HandleFunc("/vars", expVars) r.HandleFunc("/pprof/", pprof.Index) r.HandleFunc("/pprof/cmdline", pprof.Cmdline) r.HandleFunc("/pprof/profile", pprof.Profile) r.HandleFunc("/pprof/symbol", pprof.Symbol) r.HandleFunc("/pprof/trace", pprof.Trace) r.HandleFunc("/pprof/block", pprof.Handler("block").ServeHTTP) r.HandleFunc("/pprof/heap", pprof.Handler("heap").ServeHTTP) r.HandleFunc("/pprof/goroutine", pprof.Handler("goroutine").ServeHTTP) r.HandleFunc("/pprof/threadcreate", pprof.Handler("threadcreate").ServeHTTP) } ``` -
Jimmy-Xu revised this gist
Jan 21, 2017 . 1 changed file with 10 additions and 1 deletion.There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,16 +1,17 @@ #Use pprof debug docker daemon - [Use pprof debug docker daemon](#use-pprof-debug-docker-daemon) - [pprof debug entrypoint](#pprof-debug-entrypoint) - [Start docker daemon in debug mode](#start-docker-daemon-in-debug-mode) - [Run socat to make docker sock available via tcp port](#run-socat-to-make-docker-sock-available-via-tcp-port) - [Access debug url entrypoint](#access-debug-url-entrypoint) - [show global vars](#show-global-vars) - [get command line](#get-command-line) - [run pprof on your client:](#run-pprof-on-your-client) - [generate graph](#generate-graph) - [get symbol](#get-symbol) - [other](#other) # pprof debug entrypoint > source file: [docker\api\server\profiler.go](https://github.com/docker/docker/blob/master/api/server/profiler.go) @@ -98,6 +99,14 @@ $ go tool pprof http://192.168.1.137:8080/debug/pprof/profile (pprof) ``` ## generate graph ```shell $ cd /home/xjimmy/pprof $ gunzip pprof.192.168.1.137:8080.samples.cpu.001.pb.gz $ go tool pprof --pdf pprof.dockerd.192.168.1.137:8080.samples.cpu.001.pb > callgraph.pdf ``` ## get symbol ```shell -
Jimmy-Xu revised this gist
Jan 23, 2016 . 1 changed file with 55 additions and 45 deletions.There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -4,73 +4,52 @@ - [Start docker daemon in debug mode](#start-docker-daemon-in-debug-mode) - [Run socat to make docker sock available via tcp port](#run-socat-to-make-docker-sock-available-via-tcp-port) - [Access debug url entrypoint](#access-debug-url-entrypoint) - [show global vars](#show-global-vars) - [get command line](#get-command-line) - [run pprof on your client:](#run-pprof-on-your-client) - [get symbol](#get-symbol) - [other](#other) # pprof debug entrypoint > source file: [docker\api\server\profiler.go](https://github.com/docker/docker/blob/master/api/server/profiler.go) ```go func profilerSetup(mainRouter *mux.Router, path string) { var r = mainRouter.PathPrefix(path).Subrouter() r.HandleFunc("/vars", expVars) r.HandleFunc("/pprof/", pprof.Index) r.HandleFunc("/pprof/cmdline", pprof.Cmdline) r.HandleFunc("/pprof/profile", pprof.Profile) r.HandleFunc("/pprof/symbol", pprof.Symbol) r.HandleFunc("/pprof/block", pprof.Handler("block").ServeHTTP) r.HandleFunc("/pprof/heap", pprof.Handler("heap").ServeHTTP) r.HandleFunc("/pprof/goroutine", pprof.Handler("goroutine").ServeHTTP) r.HandleFunc("/pprof/threadcreate", pprof.Handler("threadcreate").ServeHTTP) } ``` # Start docker daemon in debug mode > add -D to command line ```shell $ /usr/bin/docker daemon -D -H tcp://0.0.0.0:2375 -H unix:///var/run/docker.sock ``` # Run socat to make docker sock available via tcp port > note the IP to listen at ```shell $ socat -d -d TCP-LISTEN:8080,fork,bind=192.168.1.137 UNIX:/var/run/docker.sock 2016/01/23 12:59:43 socat[3113] N listening on AF=2 192.168.1.137:8080 ``` # Access debug url entrypoint ## show global vars ```js $ curl -s http://192.168.1.137:8080/debug/vars | jq . { "cmdline": [ @@ -96,10 +75,41 @@ $ curl -s http://192.168.1.137:8080/debug/vars | jq . "Mallocs": 313164, "Frees": 199260, "HeapAlloc": 7140904, ... ``` ## get command line ```shell $ curl -s http://192.168.1.137:8080/debug/pprof/cmdline /usr/bin/docker daemon -D -H tcp://0.0.0.0:2375 -H unix:///var/run/docker.sock -api-enable-cors --storage-driver=aufs --insecure-registry registry.hyper.sh:5000 --insecure-registry 192.168.1.137:5000 ``` ## run pprof on your client: ```shell $ go tool pprof http://192.168.1.137:8080/debug/pprof/profile Fetching profile from http://192.168.1.137:8080/debug/pprof/profile Please wait... (30s) Saved profile in /home/xjimmy/pprof/pprof.192.168.1.137:8080.samples.cpu.001.pb.gz Entering interactive mode (type "help" for commands) (pprof) web (pprof) web ploop (pprof) ``` ## get symbol ```shell $ curl -s http://192.168.1.137:8080/debug/pprof/symbol num_symbols: 1 ``` ## other ``` $ culr -s http://192.168.1.137:8080/debug/pprof/block $ curl -s http://192.168.1.137:8080/debug/pprof/heap $ curl -s http://192.168.1.137:8080/debug/pprof/goroutine $ curl -s http://192.168.1.137:8080/debug/pprof/threadcreate ``` -
Jimmy-Xu revised this gist
Jan 23, 2016 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -11,7 +11,7 @@ ## pprof debug entrypoint > source file: [docker\api\server\profiler.go](https://github.com/docker/docker/blob/master/api/server/profiler.go) ```go func profilerSetup(mainRouter *mux.Router, path string) { -
Jimmy-Xu revised this gist
Jan 23, 2016 . 1 changed file with 41 additions and 16 deletions.There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,51 +1,76 @@ #Use pprof debug docker daemon - [pprof debug entrypoint](#pprof-debug-entrypoint) - [Start docker daemon in debug mode](#start-docker-daemon-in-debug-mode) - [Run socat to make docker sock available via tcp port](#run-socat-to-make-docker-sock-available-via-tcp-port) - [Access debug url entrypoint](#access-debug-url-entrypoint) - [run pprof on your client:](#run-pprof-on-your-client) - [get command line](#get-command-line) - [get symbol](#get-symbol) - [show global vars](#show-global-vars) ## pprof debug entrypoint > source file: docker\api\server\profiler.go ```go func profilerSetup(mainRouter *mux.Router, path string) { var r = mainRouter.PathPrefix(path).Subrouter() r.HandleFunc("/vars", expVars) r.HandleFunc("/pprof/", pprof.Index) r.HandleFunc("/pprof/cmdline", pprof.Cmdline) r.HandleFunc("/pprof/profile", pprof.Profile) r.HandleFunc("/pprof/symbol", pprof.Symbol) r.HandleFunc("/pprof/block", pprof.Handler("block").ServeHTTP) r.HandleFunc("/pprof/heap", pprof.Handler("heap").ServeHTTP) r.HandleFunc("/pprof/goroutine", pprof.Handler("goroutine").ServeHTTP) r.HandleFunc("/pprof/threadcreate", pprof.Handler("threadcreate").ServeHTTP) } ``` ## Start docker daemon in debug mode > add -D to command line ```shell $ /usr/bin/docker daemon -D -H tcp://0.0.0.0:2375 -H unix:///var/run/docker.sock ``` ## Run socat to make docker sock available via tcp port > note the IP to listen at ```shell $ socat -d -d TCP-LISTEN:8080,fork,bind=192.168.1.137 UNIX:/var/run/docker.sock 2016/01/23 12:59:43 socat[3113] N listening on AF=2 192.168.1.137:8080 ``` ## Access debug url entrypoint ### run pprof on your client: ```shell $ go tool pprof http://192.168.1.137:8080/debug/pprof/profile Fetching profile from http://192.168.1.137:8080/debug/pprof/profile Please wait... (30s) Saved profile in /home/xjimmy/pprof/pprof.192.168.1.137:8080.samples.cpu.001.pb.gz Entering interactive mode (type "help" for commands) (pprof) web (pprof) web ploop (pprof) ``` ### get command line ```shell $ curl -s http://192.168.1.137:8080/debug/pprof/cmdline /usr/bin/docker daemon -D -H tcp://0.0.0.0:2375 -H unix:///var/run/docker.sock -api-enable-cors --storage-driver=aufs --insecure-registry registry.hyper.sh:5000 --insecure-registry 192.168.1.137:5000 ``` ### get symbol ```shell $ curl -s http://192.168.1.137:8080/debug/pprof/symbol num_symbols: 1 ``` ### show global vars ```json $ curl -s http://192.168.1.137:8080/debug/vars | jq . { "cmdline": [ -
Jimmy-Xu revised this gist
Jan 23, 2016 . 1 changed file with 26 additions and 11 deletions.There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,16 +1,26 @@ #Use pprof debug docker daemon - [Start docker daemon in debug mode(add -D)](#start-docker-daemon-in-debug-modeadd-d) - [Run socat to make docker sock available via tcp port (note the IP to listen at)](#run-socat-to-make-docker-sock-available-via-tcp-port-note-the-ip-to-listen-at) - [Access debug url entrypoint](#access-debug-url-entrypoint) - [run pprof on your client:](#run-pprof-on-your-client) - [get command line](#get-command-line) - [get symbol](#get-symbol) - [show global vars](#show-global-vars) ## Start docker daemon in debug mode(add -D) ``` $ /usr/bin/docker daemon -D -H tcp://0.0.0.0:2375 -H unix:///var/run/docker.sock ``` ## Run socat to make docker sock available via tcp port (note the IP to listen at) ``` $ socat -d -d TCP-LISTEN:8080,fork,bind=192.168.1.137 UNIX:/var/run/docker.sock ``` ## Access debug url entrypoint ### run pprof on your client: ``` $ go tool pprof http://192.168.1.137:8080/debug/pprof/profile Fetching profile from http://192.168.1.137:8080/debug/pprof/profile @@ -22,7 +32,18 @@ Entering interactive mode (type "help" for commands) (pprof) ``` ### get command line ``` $ curl -s http://192.168.1.137:8080/debug/pprof/cmdline /usr/bin/docker daemon -D -H tcp://0.0.0.0:2375 -H unix:///var/run/docker.sock -api-enable-cors --storage-driver=aufs --insecure-registry registry.hyper.sh:5000 --insecure-registry 192.168.1.137:5000 ``` ### get symbol ``` $ curl -s http://192.168.1.137:8080/debug/pprof/symbol num_symbols: 1 ``` ### show global vars ``` $ curl -s http://192.168.1.137:8080/debug/vars | jq . @@ -57,9 +78,3 @@ $ curl -s http://192.168.1.137:8080/debug/vars | jq . "HeapObjects": 113904, ... ``` -
Jimmy-Xu revised this gist
Jan 23, 2016 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -25,7 +25,7 @@ Entering interactive mode (type "help" for commands) ##debug url entrypoint ### show global vars ``` $ curl -s http://192.168.1.137:8080/debug/vars | jq . { "cmdline": [ "/usr/bin/docker", -
Jimmy-Xu revised this gist
Jan 23, 2016 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -61,5 +61,5 @@ $ curl -s http://192.168.1.137:8080/debug/vars ### get command line ``` $ curl -s http://192.168.1.137:8080/debug/pprof/cmdline /usr/bin/docker daemon -D -H tcp://0.0.0.0:2375 -H unix:///var/run/docker.sock -api-enable-cors --storage-driver=aufs --insecure-registry registry.hyper.sh:5000 --insecure-registry 192.168.1.137:5000 ``` -
Jimmy-Xu revised this gist
Jan 23, 2016 . 1 changed file with 47 additions and 3 deletions.There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,14 +1,16 @@ #use pprof debug docker daemon ##Start docker daemon in debug mode(add -D) ``` $ /usr/bin/docker daemon -D -H tcp://0.0.0.0:2375 -H unix:///var/run/docker.sock ``` ##Run socat to make docker sock available via tcp port (note the IP to listen at) ``` $ socat -d -d TCP-LISTEN:8080,fork,bind=192.168.1.137 UNIX:/var/run/docker.sock ``` ##Run pprof on your client: ``` $ go tool pprof http://192.168.1.137:8080/debug/pprof/profile Fetching profile from http://192.168.1.137:8080/debug/pprof/profile @@ -18,4 +20,46 @@ Entering interactive mode (type "help" for commands) (pprof) web (pprof) web ploop (pprof) ``` ##debug url entrypoint ### show global vars ``` $ curl -s http://192.168.1.137:8080/debug/vars { "cmdline": [ "/usr/bin/docker", "daemon", "-D", "-H", "tcp://0.0.0.0:2375", "-H", "unix:///var/run/docker.sock", "-api-enable-cors", "--storage-driver=aufs", "--insecure-registry", "registry.hyper.sh:5000", "--insecure-registry", "192.168.1.137:5000" ], "memstats": { "Alloc": 7140904, "TotalAlloc": 20379824, "Sys": 14559480, "Lookups": 3090, "Mallocs": 313164, "Frees": 199260, "HeapAlloc": 7140904, "HeapSys": 11124736, "HeapIdle": 1720320, "HeapInuse": 9404416, "HeapReleased": 1687552, "HeapObjects": 113904, ... ``` ### get command line ``` $ curl -s http://192.168.1.137:8080/debug/pprof/cmdline /usr/bin/dockerdaemon-D-Htcp://0.0.0.0:2375-Hunix:///var/run/docker.sock-api-enable-cors--storage-driver=aufs--insecure-registryregistry.hyper.sh:5000--insecure-registry192.168.1.137:5000 ``` -
Jimmy-Xu revised this gist
Jan 23, 2016 . 2 changed files with 21 additions and 15 deletions.There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,15 +0,0 @@ This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,21 @@ #Start docker daemon in debug mode(add -D) ``` $ /usr/bin/docker daemon -D -H tcp://0.0.0.0:2375 -H unix:///var/run/docker.sock ``` #Run socat to make docker sock available via tcp port (note the IP to listen at) ``` $ socat -d -d TCP-LISTEN:8080,fork,bind=192.168.1.137 UNIX:/var/run/docker.sock ``` #Run pprof on your client: ``` $ go tool pprof http://192.168.1.137:8080/debug/pprof/profile Fetching profile from http://192.168.1.137:8080/debug/pprof/profile Please wait... (30s) Saved profile in /home/xjimmy/pprof/pprof.192.168.1.137:8080.samples.cpu.001.pb.gz Entering interactive mode (type "help" for commands) (pprof) web (pprof) web ploop (pprof) ``` -
Jimmy-Xu revised this gist
Jan 23, 2016 . 1 changed file with 11 additions and 11 deletions.There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,15 +1,15 @@ Start docker daemon in debug mode(add -D) $ /usr/bin/docker daemon -D -H tcp://0.0.0.0:2375 -H unix:///var/run/docker.sock Run socat to make docker sock available via tcp port (note the IP to listen at) $ socat -d -d TCP-LISTEN:8080,fork,bind=192.168.1.137 UNIX:/var/run/docker.sock Run pprof on your client: $ go tool pprof http://192.168.1.137:8080/debug/pprof/profile Fetching profile from http://192.168.1.137:8080/debug/pprof/profile Please wait... (30s) Saved profile in /home/xjimmy/pprof/pprof.192.168.1.137:8080.samples.cpu.001.pb.gz Entering interactive mode (type "help" for commands) (pprof) web (pprof) web ploop (pprof) -
kolyshkin created this gist
Aug 12, 2015 .There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,15 @@ Enable port 8080 through the firewall: firewall-cmd --add-port=8080/tcp Run socat to make docker sock available via tcp port (note the IP to listen at) socat -d -d TCP-LISTEN:8080,fork,bind=192.168.122.214 UNIX:/var/run/docker.sock Run pprof on your client: go tool pprof http://192.168.122.214:8080/debug/pprof/profile Fetching profile from http://192.168.122.214:8080/debug/pprof/profile Please wait... (30s) Saved profile in /home/kir/pprof/pprof.192.168.122.214:8080.samples.cpu.002.pb.gz Entering interactive mode (type "help" for commands) (pprof) web (pprof) web ploop (pprof)