mirror of
https://github.com/moby/moby.git
synced 2022-11-09 12:21:53 -05:00
Expose # of CPUs and memory available on docker info.
Signed-off-by: Andrea Luzzardi <aluzzardi@gmail.com>
This commit is contained in:
parent
c681bea062
commit
61f8001c23
6 changed files with 27 additions and 0 deletions
|
@ -481,6 +481,13 @@ func (cli *DockerCli) CmdInfo(args ...string) error {
|
||||||
fmt.Fprintf(cli.out, "Kernel Version: %s\n", remoteInfo.Get("KernelVersion"))
|
fmt.Fprintf(cli.out, "Kernel Version: %s\n", remoteInfo.Get("KernelVersion"))
|
||||||
fmt.Fprintf(cli.out, "Operating System: %s\n", remoteInfo.Get("OperatingSystem"))
|
fmt.Fprintf(cli.out, "Operating System: %s\n", remoteInfo.Get("OperatingSystem"))
|
||||||
|
|
||||||
|
if remoteInfo.Exists("NCPU") {
|
||||||
|
fmt.Fprintf(cli.out, "CPUs: %d\n", remoteInfo.GetInt("NCPU"))
|
||||||
|
}
|
||||||
|
if remoteInfo.Exists("MemTotal") {
|
||||||
|
fmt.Fprintf(cli.out, "Total Memory: %s\n", units.BytesSize(float64(remoteInfo.GetInt64("MemTotal"))))
|
||||||
|
}
|
||||||
|
|
||||||
if remoteInfo.GetBool("Debug") || os.Getenv("DEBUG") != "" {
|
if remoteInfo.GetBool("Debug") || os.Getenv("DEBUG") != "" {
|
||||||
fmt.Fprintf(cli.out, "Debug mode (server): %v\n", remoteInfo.GetBool("Debug"))
|
fmt.Fprintf(cli.out, "Debug mode (server): %v\n", remoteInfo.GetBool("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") != "")
|
||||||
|
|
|
@ -9,6 +9,7 @@ import (
|
||||||
"github.com/docker/docker/pkg/log"
|
"github.com/docker/docker/pkg/log"
|
||||||
"github.com/docker/docker/pkg/parsers/kernel"
|
"github.com/docker/docker/pkg/parsers/kernel"
|
||||||
"github.com/docker/docker/pkg/parsers/operatingsystem"
|
"github.com/docker/docker/pkg/parsers/operatingsystem"
|
||||||
|
"github.com/docker/docker/pkg/system"
|
||||||
"github.com/docker/docker/registry"
|
"github.com/docker/docker/registry"
|
||||||
"github.com/docker/docker/utils"
|
"github.com/docker/docker/utils"
|
||||||
)
|
)
|
||||||
|
@ -37,6 +38,11 @@ func (daemon *Daemon) CmdInfo(job *engine.Job) engine.Status {
|
||||||
operatingSystem += " (containerized)"
|
operatingSystem += " (containerized)"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
meminfo, err := system.ReadMemInfo()
|
||||||
|
if err != nil {
|
||||||
|
log.Errorf("Could not read system memory info: %v", err)
|
||||||
|
}
|
||||||
|
|
||||||
// if we still have the original dockerinit binary from before we copied it locally, let's return the path to that, since that's more intuitive (the copied path is trivial to derive by hand given VERSION)
|
// if we still have the original dockerinit binary from before we copied it locally, let's return the path to that, since that's more intuitive (the copied path is trivial to derive by hand given VERSION)
|
||||||
initPath := utils.DockerInitPath("")
|
initPath := utils.DockerInitPath("")
|
||||||
if initPath == "" {
|
if initPath == "" {
|
||||||
|
@ -67,6 +73,8 @@ func (daemon *Daemon) CmdInfo(job *engine.Job) engine.Status {
|
||||||
v.Set("IndexServerAddress", registry.IndexServerAddress())
|
v.Set("IndexServerAddress", registry.IndexServerAddress())
|
||||||
v.Set("InitSha1", dockerversion.INITSHA1)
|
v.Set("InitSha1", dockerversion.INITSHA1)
|
||||||
v.Set("InitPath", initPath)
|
v.Set("InitPath", initPath)
|
||||||
|
v.SetInt("NCPU", runtime.NumCPU())
|
||||||
|
v.SetInt64("MemTotal", meminfo.MemTotal)
|
||||||
if _, err := v.WriteTo(job.Stdout); err != nil {
|
if _, err := v.WriteTo(job.Stdout); err != nil {
|
||||||
return job.Error(err)
|
return job.Error(err)
|
||||||
}
|
}
|
||||||
|
|
|
@ -37,6 +37,8 @@ Here is a sample output:
|
||||||
Execution Driver: native-0.2
|
Execution Driver: native-0.2
|
||||||
Kernel Version: 3.13.0-24-generic
|
Kernel Version: 3.13.0-24-generic
|
||||||
Operating System: Ubuntu 14.04 LTS
|
Operating System: Ubuntu 14.04 LTS
|
||||||
|
CPUs: 1
|
||||||
|
Total Memory: 2 GiB
|
||||||
|
|
||||||
# HISTORY
|
# HISTORY
|
||||||
April 2014, Originally compiled by William Henry (whenry at redhat dot com)
|
April 2014, Originally compiled by William Henry (whenry at redhat dot com)
|
||||||
|
|
|
@ -44,6 +44,12 @@ You can still call an old version of the API using
|
||||||
|
|
||||||
### What's new
|
### What's new
|
||||||
|
|
||||||
|
`GET /info`
|
||||||
|
|
||||||
|
**New!**
|
||||||
|
`info` now returns the number of CPUs available on the machine (`NCPU`) and
|
||||||
|
total memory available (`MemTotal`).
|
||||||
|
|
||||||
## v1.15
|
## v1.15
|
||||||
|
|
||||||
### Full Documentation
|
### Full Documentation
|
||||||
|
|
|
@ -1164,6 +1164,8 @@ Display system-wide information
|
||||||
"Driver":"btrfs",
|
"Driver":"btrfs",
|
||||||
"ExecutionDriver":"native-0.1",
|
"ExecutionDriver":"native-0.1",
|
||||||
"KernelVersion":"3.12.0-1-amd64"
|
"KernelVersion":"3.12.0-1-amd64"
|
||||||
|
"NCPU":1,
|
||||||
|
"MemTotal":2099236864,
|
||||||
"Debug":false,
|
"Debug":false,
|
||||||
"NFd": 11,
|
"NFd": 11,
|
||||||
"NGoroutines":21,
|
"NGoroutines":21,
|
||||||
|
|
|
@ -812,6 +812,8 @@ For example:
|
||||||
Execution Driver: native-0.2
|
Execution Driver: native-0.2
|
||||||
Kernel Version: 3.13.0-24-generic
|
Kernel Version: 3.13.0-24-generic
|
||||||
Operating System: Ubuntu 14.04 LTS
|
Operating System: Ubuntu 14.04 LTS
|
||||||
|
CPUs: 1
|
||||||
|
Total Memory: 2 GiB
|
||||||
Debug mode (server): false
|
Debug mode (server): false
|
||||||
Debug mode (client): true
|
Debug mode (client): true
|
||||||
Fds: 10
|
Fds: 10
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue