Browse Source

Merge pull request #33 from alexlarsson/dm-plugin-status

Add driver plugin status
Michael Crosby 11 years ago
parent
commit
7cad77b1e2
7 changed files with 44 additions and 9 deletions
  1. 11 9
      api_params.go
  2. 4 0
      aufs/aufs.go
  3. 4 0
      commands.go
  4. 15 0
      devmapper/driver.go
  5. 4 0
      graphdriver/driver.go
  6. 4 0
      graphdriver/dummy/driver.go
  7. 2 0
      server.go

+ 11 - 9
api_params.go

@@ -52,15 +52,17 @@ type APIInfo struct {
 	Debug              bool
 	Debug              bool
 	Containers         int
 	Containers         int
 	Images             int
 	Images             int
-	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 {
 type APITop struct {

+ 4 - 0
aufs/aufs.go

@@ -103,6 +103,10 @@ func (a *AufsDriver) String() string {
 	return "aufs"
 	return "aufs"
 }
 }
 
 
+func (d *AufsDriver) Status() [][2]string {
+	return nil
+}
+
 // Three folders are created for each id
 // Three folders are created for each id
 // mnt, layers, and diff
 // mnt, layers, and diff
 func (a *AufsDriver) Create(id, parent string) error {
 func (a *AufsDriver) Create(id, parent string) error {

+ 4 - 0
commands.go

@@ -460,6 +460,10 @@ func (cli *DockerCli) CmdInfo(args ...string) error {
 
 
 	fmt.Fprintf(cli.out, "Containers: %d\n", out.Containers)
 	fmt.Fprintf(cli.out, "Containers: %d\n", out.Containers)
 	fmt.Fprintf(cli.out, "Images: %d\n", out.Images)
 	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") != "" {
 	if out.Debug || os.Getenv("DEBUG") != "" {
 		fmt.Fprintf(cli.out, "Debug mode (server): %v\n", out.Debug)
 		fmt.Fprintf(cli.out, "Debug mode (server): %v\n", out.Debug)
 		fmt.Fprintf(cli.out, "Debug mode (client): %v\n", os.Getenv("DEBUG") != "")
 		fmt.Fprintf(cli.out, "Debug mode (client): %v\n", os.Getenv("DEBUG") != "")

+ 15 - 0
devmapper/driver.go

@@ -37,6 +37,21 @@ func (d *Driver) String() string {
 	return "devicemapper"
 	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 {
 func (d *Driver) Cleanup() error {
 	return d.DeviceSet.Shutdown()
 	return d.DeviceSet.Shutdown()
 }
 }

+ 4 - 0
graphdriver/driver.go

@@ -11,12 +11,16 @@ import (
 type InitFunc func(root string) (Driver, error)
 type InitFunc func(root string) (Driver, error)
 
 
 type Driver interface {
 type Driver interface {
+	String() string
+
 	Create(id, parent string) error
 	Create(id, parent string) error
 	Remove(id string) error
 	Remove(id string) error
 
 
 	Get(id string) (dir string, err error)
 	Get(id string) (dir string, err error)
 	Size(id string) (bytes int64, err error)
 	Size(id string) (bytes int64, err error)
 
 
+	Status() [][2]string
+
 	Cleanup() error
 	Cleanup() error
 }
 }
 
 

+ 4 - 0
graphdriver/dummy/driver.go

@@ -27,6 +27,10 @@ func (d *Driver) String() string {
 	return "dummy"
 	return "dummy"
 }
 }
 
 
+func (d *Driver) Status() [][2]string {
+	return nil
+}
+
 func (d *Driver) Cleanup() error {
 func (d *Driver) Cleanup() error {
 	return nil
 	return nil
 }
 }

+ 2 - 0
server.go

@@ -375,6 +375,8 @@ func (srv *Server) DockerInfo() *APIInfo {
 	return &APIInfo{
 	return &APIInfo{
 		Containers:         len(srv.runtime.List()),
 		Containers:         len(srv.runtime.List()),
 		Images:             imgcount,
 		Images:             imgcount,
+		Driver:             srv.runtime.driver.String(),
+		DriverStatus:       srv.runtime.driver.Status(),
 		MemoryLimit:        srv.runtime.capabilities.MemoryLimit,
 		MemoryLimit:        srv.runtime.capabilities.MemoryLimit,
 		SwapLimit:          srv.runtime.capabilities.SwapLimit,
 		SwapLimit:          srv.runtime.capabilities.SwapLimit,
 		IPv4Forwarding:     !srv.runtime.capabilities.IPv4ForwardingDisabled,
 		IPv4Forwarding:     !srv.runtime.capabilities.IPv4ForwardingDisabled,