Thanks to visit codestin.com
Credit goes to github.com

Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions api/client/commands.go
Original file line number Diff line number Diff line change
Expand Up @@ -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, "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") != "" {
fmt.Fprintf(cli.out, "Debug mode (server): %v\n", remoteInfo.GetBool("Debug"))
fmt.Fprintf(cli.out, "Debug mode (client): %v\n", os.Getenv("DEBUG") != "")
Expand Down
8 changes: 8 additions & 0 deletions daemon/info.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import (
"github.com/docker/docker/pkg/log"
"github.com/docker/docker/pkg/parsers/kernel"
"github.com/docker/docker/pkg/parsers/operatingsystem"
"github.com/docker/docker/pkg/system"
"github.com/docker/docker/registry"
"github.com/docker/docker/utils"
)
Expand Down Expand Up @@ -37,6 +38,11 @@ func (daemon *Daemon) CmdInfo(job *engine.Job) engine.Status {
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)
initPath := utils.DockerInitPath("")
if initPath == "" {
Expand Down Expand Up @@ -67,6 +73,8 @@ func (daemon *Daemon) CmdInfo(job *engine.Job) engine.Status {
v.Set("IndexServerAddress", registry.IndexServerAddress())
v.Set("InitSha1", dockerversion.INITSHA1)
v.Set("InitPath", initPath)
v.SetInt("NCPU", runtime.NumCPU())
v.SetInt64("MemTotal", meminfo.MemTotal)
if _, err := v.WriteTo(job.Stdout); err != nil {
return job.Error(err)
}
Expand Down
2 changes: 2 additions & 0 deletions docs/man/docker-info.1.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,8 @@ Here is a sample output:
Execution Driver: native-0.2
Kernel Version: 3.13.0-24-generic
Operating System: Ubuntu 14.04 LTS
CPUs: 1
Total Memory: 2 GiB

# HISTORY
April 2014, Originally compiled by William Henry (whenry at redhat dot com)
Expand Down
6 changes: 6 additions & 0 deletions docs/sources/reference/api/docker_remote_api.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,12 @@ You can still call an old version of the API using

### 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

### Full Documentation
Expand Down
2 changes: 2 additions & 0 deletions docs/sources/reference/api/docker_remote_api_v1.16.md
Original file line number Diff line number Diff line change
Expand Up @@ -1164,6 +1164,8 @@ Display system-wide information
"Driver":"btrfs",
"ExecutionDriver":"native-0.1",
"KernelVersion":"3.12.0-1-amd64"
"NCPU":1,
"MemTotal":2099236864,
"Debug":false,
"NFd": 11,
"NGoroutines":21,
Expand Down
2 changes: 2 additions & 0 deletions docs/sources/reference/commandline/cli.md
Original file line number Diff line number Diff line change
Expand Up @@ -812,6 +812,8 @@ For example:
Execution Driver: native-0.2
Kernel Version: 3.13.0-24-generic
Operating System: Ubuntu 14.04 LTS
CPUs: 1
Total Memory: 2 GiB
Debug mode (server): false
Debug mode (client): true
Fds: 10
Expand Down