mirror of
https://github.com/moby/moby.git
synced 2022-11-09 12:21:53 -05:00
Merge pull request #772 from dotcloud/improve_version_info_cmds
* API: Improve version info cmds
This commit is contained in:
commit
0443cc351d
4 changed files with 53 additions and 43 deletions
|
@ -3,7 +3,7 @@ package docker
|
||||||
type ApiHistory struct {
|
type ApiHistory struct {
|
||||||
Id string
|
Id string
|
||||||
Created int64
|
Created int64
|
||||||
CreatedBy string
|
CreatedBy string `json:",omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type ApiImages struct {
|
type ApiImages struct {
|
||||||
|
@ -14,13 +14,13 @@ type ApiImages struct {
|
||||||
}
|
}
|
||||||
|
|
||||||
type ApiInfo struct {
|
type ApiInfo struct {
|
||||||
Containers int
|
|
||||||
Version string
|
|
||||||
Images int
|
|
||||||
Debug bool
|
Debug bool
|
||||||
GoVersion string
|
Containers int
|
||||||
NFd int `json:",omitempty"`
|
Images int
|
||||||
NGoroutines int `json:",omitempty"`
|
NFd int `json:",omitempty"`
|
||||||
|
NGoroutines int `json:",omitempty"`
|
||||||
|
MemoryLimit bool `json:",omitempty"`
|
||||||
|
SwapLimit bool `json:",omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type ApiContainers struct {
|
type ApiContainers struct {
|
||||||
|
@ -43,7 +43,7 @@ type ApiId struct {
|
||||||
|
|
||||||
type ApiRun struct {
|
type ApiRun struct {
|
||||||
Id string
|
Id string
|
||||||
Warnings []string
|
Warnings []string `json:",omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type ApiPort struct {
|
type ApiPort struct {
|
||||||
|
@ -51,10 +51,9 @@ type ApiPort struct {
|
||||||
}
|
}
|
||||||
|
|
||||||
type ApiVersion struct {
|
type ApiVersion struct {
|
||||||
Version string
|
Version string
|
||||||
GitCommit string
|
GitCommit string `json:",omitempty"`
|
||||||
MemoryLimit bool
|
GoVersion string `json:",omitempty"`
|
||||||
SwapLimit bool
|
|
||||||
}
|
}
|
||||||
|
|
||||||
type ApiWait struct {
|
type ApiWait struct {
|
||||||
|
|
34
commands.go
34
commands.go
|
@ -392,15 +392,14 @@ func (cli *DockerCli) CmdVersion(args ...string) error {
|
||||||
utils.Debugf("Error unmarshal: body: %s, err: %s\n", body, err)
|
utils.Debugf("Error unmarshal: body: %s, err: %s\n", body, err)
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
fmt.Println("Version:", out.Version)
|
fmt.Println("Client version:", VERSION)
|
||||||
fmt.Println("Git Commit:", out.GitCommit)
|
fmt.Println("Server version:", out.Version)
|
||||||
if !out.MemoryLimit {
|
if out.GitCommit != "" {
|
||||||
fmt.Println("WARNING: No memory limit support")
|
fmt.Println("Git commit:", out.GitCommit)
|
||||||
}
|
}
|
||||||
if !out.SwapLimit {
|
if out.GoVersion != "" {
|
||||||
fmt.Println("WARNING: No swap limit support")
|
fmt.Println("Go version:", out.GoVersion)
|
||||||
}
|
}
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -421,14 +420,23 @@ func (cli *DockerCli) CmdInfo(args ...string) error {
|
||||||
}
|
}
|
||||||
|
|
||||||
var out ApiInfo
|
var out ApiInfo
|
||||||
err = json.Unmarshal(body, &out)
|
if err := json.Unmarshal(body, &out); err != nil {
|
||||||
if err != nil {
|
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
fmt.Printf("containers: %d\nversion: %s\nimages: %d\nGo version: %s\n", out.Containers, out.Version, out.Images, out.GoVersion)
|
|
||||||
if out.Debug {
|
fmt.Printf("Containers: %d\n", out.Containers)
|
||||||
fmt.Println("debug mode enabled")
|
fmt.Printf("Images: %d\n", out.Images)
|
||||||
fmt.Printf("fds: %d\ngoroutines: %d\n", out.NFd, out.NGoroutines)
|
if out.Debug || os.Getenv("DEBUG") != "" {
|
||||||
|
fmt.Printf("Debug mode (server): %v\n", out.Debug)
|
||||||
|
fmt.Printf("Debug mode (client): %v\n", os.Getenv("DEBUG") != "")
|
||||||
|
fmt.Printf("Fds: %d\n", out.NFd)
|
||||||
|
fmt.Printf("Goroutines: %d\n", out.NGoroutines)
|
||||||
|
}
|
||||||
|
if !out.MemoryLimit {
|
||||||
|
fmt.Println("WARNING: No memory limit support")
|
||||||
|
}
|
||||||
|
if !out.SwapLimit {
|
||||||
|
fmt.Println("WARNING: No swap limit support")
|
||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
|
@ -957,10 +957,12 @@ Display system-wide information
|
||||||
|
|
||||||
{
|
{
|
||||||
"Containers":11,
|
"Containers":11,
|
||||||
"Version":"0.2.2",
|
|
||||||
"Images":16,
|
"Images":16,
|
||||||
"GoVersion":"go1.0.3",
|
"Debug":false,
|
||||||
"Debug":false
|
"NFd": 11,
|
||||||
|
"NGoroutines":21,
|
||||||
|
"MemoryLimit":true,
|
||||||
|
"SwapLimit":false
|
||||||
}
|
}
|
||||||
|
|
||||||
:statuscode 200: no error
|
:statuscode 200: no error
|
||||||
|
@ -990,8 +992,7 @@ Show the docker version information
|
||||||
{
|
{
|
||||||
"Version":"0.2.2",
|
"Version":"0.2.2",
|
||||||
"GitCommit":"5a2a5cc+CHANGES",
|
"GitCommit":"5a2a5cc+CHANGES",
|
||||||
"MemoryLimit":true,
|
"GoVersion":"go1.0.3"
|
||||||
"SwapLimit":false
|
|
||||||
}
|
}
|
||||||
|
|
||||||
:statuscode 200: no error
|
:statuscode 200: no error
|
||||||
|
|
26
server.go
26
server.go
|
@ -17,7 +17,11 @@ import (
|
||||||
)
|
)
|
||||||
|
|
||||||
func (srv *Server) DockerVersion() ApiVersion {
|
func (srv *Server) DockerVersion() ApiVersion {
|
||||||
return ApiVersion{VERSION, GIT_COMMIT, srv.runtime.capabilities.MemoryLimit, srv.runtime.capabilities.SwapLimit}
|
return ApiVersion{
|
||||||
|
Version: VERSION,
|
||||||
|
GitCommit: GIT_COMMIT,
|
||||||
|
GoVersion: runtime.Version(),
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (srv *Server) ContainerKill(name string) error {
|
func (srv *Server) ContainerKill(name string) error {
|
||||||
|
@ -187,7 +191,7 @@ func (srv *Server) Images(all bool, filter string) ([]ApiImages, error) {
|
||||||
return outs, nil
|
return outs, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (srv *Server) DockerInfo() ApiInfo {
|
func (srv *Server) DockerInfo() *ApiInfo {
|
||||||
images, _ := srv.runtime.graph.All()
|
images, _ := srv.runtime.graph.All()
|
||||||
var imgcount int
|
var imgcount int
|
||||||
if images == nil {
|
if images == nil {
|
||||||
|
@ -195,17 +199,15 @@ func (srv *Server) DockerInfo() ApiInfo {
|
||||||
} else {
|
} else {
|
||||||
imgcount = len(images)
|
imgcount = len(images)
|
||||||
}
|
}
|
||||||
var out ApiInfo
|
return &ApiInfo{
|
||||||
out.Containers = len(srv.runtime.List())
|
Containers: len(srv.runtime.List()),
|
||||||
out.Version = VERSION
|
Images: imgcount,
|
||||||
out.Images = imgcount
|
MemoryLimit: srv.runtime.capabilities.MemoryLimit,
|
||||||
out.GoVersion = runtime.Version()
|
SwapLimit: srv.runtime.capabilities.SwapLimit,
|
||||||
if os.Getenv("DEBUG") != "" {
|
Debug: os.Getenv("DEBUG") != "",
|
||||||
out.Debug = true
|
NFd: utils.GetTotalUsedFds(),
|
||||||
out.NFd = utils.GetTotalUsedFds()
|
NGoroutines: runtime.NumGoroutine(),
|
||||||
out.NGoroutines = runtime.NumGoroutine()
|
|
||||||
}
|
}
|
||||||
return out
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (srv *Server) ImageHistory(name string) ([]ApiHistory, error) {
|
func (srv *Server) ImageHistory(name string) ([]ApiHistory, error) {
|
||||||
|
|
Loading…
Add table
Reference in a new issue