mirror of
https://github.com/moby/moby.git
synced 2022-11-09 12:21:53 -05:00
Print devicemapper status details in docker info
This adds a generic Status call in the Driver api and implements if for the devicemapper backend. The status is an array of key/value strings rather than a map so that we can guarantee some static order of the docker info output.
This commit is contained in:
parent
062810caed
commit
243843c078
7 changed files with 40 additions and 10 deletions
|
@ -52,16 +52,17 @@ type APIInfo struct {
|
|||
Debug bool
|
||||
Containers int
|
||||
Images int
|
||||
Driver string `json:",omitempty"`
|
||||
NFd int `json:",omitempty"`
|
||||
NGoroutines int `json:",omitempty"`
|
||||
MemoryLimit bool `json:",omitempty"`
|
||||
SwapLimit bool `json:",omitempty"`
|
||||
IPv4Forwarding bool `json:",omitempty"`
|
||||
LXCVersion string `json:",omitempty"`
|
||||
NEventsListener int `json:",omitempty"`
|
||||
KernelVersion string `json:",omitempty"`
|
||||
IndexServerAddress string `json:",omitempty"`
|
||||
Driver string `json:",omitempty"`
|
||||
DriverStatus [][2]string `json:",omitempty"`
|
||||
NFd int `json:",omitempty"`
|
||||
NGoroutines int `json:",omitempty"`
|
||||
MemoryLimit bool `json:",omitempty"`
|
||||
SwapLimit bool `json:",omitempty"`
|
||||
IPv4Forwarding bool `json:",omitempty"`
|
||||
LXCVersion string `json:",omitempty"`
|
||||
NEventsListener int `json:",omitempty"`
|
||||
KernelVersion string `json:",omitempty"`
|
||||
IndexServerAddress string `json:",omitempty"`
|
||||
}
|
||||
|
||||
type APITop struct {
|
||||
|
|
|
@ -103,6 +103,10 @@ func (a *AufsDriver) String() string {
|
|||
return "aufs"
|
||||
}
|
||||
|
||||
func (d *AufsDriver) Status() [][2]string {
|
||||
return nil
|
||||
}
|
||||
|
||||
// Three folders are created for each id
|
||||
// mnt, layers, and diff
|
||||
func (a *AufsDriver) Create(id, parent string) error {
|
||||
|
|
|
@ -461,6 +461,9 @@ func (cli *DockerCli) CmdInfo(args ...string) error {
|
|||
fmt.Fprintf(cli.out, "Containers: %d\n", out.Containers)
|
||||
fmt.Fprintf(cli.out, "Images: %d\n", out.Images)
|
||||
fmt.Fprintf(cli.out, "Driver: %s\n", out.Driver)
|
||||
for _, pair := range out.DriverStatus {
|
||||
fmt.Fprintf(cli.out, " %s: %s\n", pair[0], pair[1])
|
||||
}
|
||||
if out.Debug || os.Getenv("DEBUG") != "" {
|
||||
fmt.Fprintf(cli.out, "Debug mode (server): %v\n", out.Debug)
|
||||
fmt.Fprintf(cli.out, "Debug mode (client): %v\n", os.Getenv("DEBUG") != "")
|
||||
|
|
|
@ -37,6 +37,21 @@ func (d *Driver) String() string {
|
|||
return "devicemapper"
|
||||
}
|
||||
|
||||
func (d *Driver) Status() [][2]string {
|
||||
s := d.DeviceSet.Status()
|
||||
|
||||
status := [][2]string{
|
||||
{"Pool Name", s.PoolName},
|
||||
{"Data file", s.DataLoopback},
|
||||
{"Metadata file", s.MetadataLoopback},
|
||||
{"Data Space Used", fmt.Sprintf("%.1f Mb", float64(s.Data.Used)/(1024*1024))},
|
||||
{"Data Space Total", fmt.Sprintf("%.1f Mb", float64(s.Data.Total)/(1024*1024))},
|
||||
{"Metadata Space Used", fmt.Sprintf("%.1f Mb", float64(s.Metadata.Used)/(1024*1024))},
|
||||
{"Metadata Space Total", fmt.Sprintf("%.1f Mb", float64(s.Metadata.Total)/(1024*1024))},
|
||||
}
|
||||
return status
|
||||
}
|
||||
|
||||
func (d *Driver) Cleanup() error {
|
||||
return d.DeviceSet.Shutdown()
|
||||
}
|
||||
|
|
|
@ -19,6 +19,8 @@ type Driver interface {
|
|||
Get(id string) (dir string, err error)
|
||||
Size(id string) (bytes int64, err error)
|
||||
|
||||
Status() [][2]string
|
||||
|
||||
Cleanup() error
|
||||
}
|
||||
|
||||
|
|
|
@ -27,6 +27,10 @@ func (d *Driver) String() string {
|
|||
return "dummy"
|
||||
}
|
||||
|
||||
func (d *Driver) Status() [][2]string {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (d *Driver) Cleanup() error {
|
||||
return nil
|
||||
}
|
||||
|
|
|
@ -376,6 +376,7 @@ func (srv *Server) DockerInfo() *APIInfo {
|
|||
Containers: len(srv.runtime.List()),
|
||||
Images: imgcount,
|
||||
Driver: srv.runtime.driver.String(),
|
||||
DriverStatus: srv.runtime.driver.Status(),
|
||||
MemoryLimit: srv.runtime.capabilities.MemoryLimit,
|
||||
SwapLimit: srv.runtime.capabilities.SwapLimit,
|
||||
IPv4Forwarding: !srv.runtime.capabilities.IPv4ForwardingDisabled,
|
||||
|
|
Loading…
Reference in a new issue