зеркало из https://github.com/microsoft/docker.git
Add debug infos in CmdInfo to know the amount of fds and goroutines in use
This commit is contained in:
Родитель
b336d928fe
Коммит
99f9b69716
|
@ -203,6 +203,12 @@ func (srv *Server) CmdInfo(stdin io.ReadCloser, stdout io.Writer, args ...string
|
||||||
len(srv.runtime.List()),
|
len(srv.runtime.List()),
|
||||||
VERSION,
|
VERSION,
|
||||||
imgcount)
|
imgcount)
|
||||||
|
|
||||||
|
if !rcli.DEBUG_FLAG {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
fmt.Fprintf(stdout, "debug mode enabled\n")
|
||||||
|
fmt.Fprintf(stdout, "fds: %d\ngoroutines: %d\n", getTotalUsedFds(), runtime.NumGoroutine())
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
10
utils.go
10
utils.go
|
@ -7,6 +7,7 @@ import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"github.com/dotcloud/docker/rcli"
|
"github.com/dotcloud/docker/rcli"
|
||||||
"io"
|
"io"
|
||||||
|
"io/ioutil"
|
||||||
"net/http"
|
"net/http"
|
||||||
"os"
|
"os"
|
||||||
"os/exec"
|
"os/exec"
|
||||||
|
@ -260,3 +261,12 @@ func (w *writeBroadcaster) Close() error {
|
||||||
func newWriteBroadcaster() *writeBroadcaster {
|
func newWriteBroadcaster() *writeBroadcaster {
|
||||||
return &writeBroadcaster{list.New()}
|
return &writeBroadcaster{list.New()}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func getTotalUsedFds() int {
|
||||||
|
if fds, err := ioutil.ReadDir(fmt.Sprintf("/proc/%d/fd", os.Getpid())); err != nil {
|
||||||
|
Debugf("Error opening /proc/%d/fd: %s", os.Getpid(), err)
|
||||||
|
} else {
|
||||||
|
return len(fds)
|
||||||
|
}
|
||||||
|
return -1
|
||||||
|
}
|
||||||
|
|
Загрузка…
Ссылка в новой задаче