mirror of https://github.com/docker/docs.git
Merge pull request #17478 from vdemeester/pr-13921
Carry#13921 : Expand /info: Expose OSType (GOOS), Architecture (GOARCH)
This commit is contained in:
commit
104dab87ea
|
@ -59,6 +59,8 @@ func (cli *DockerCli) CmdInfo(args ...string) error {
|
||||||
|
|
||||||
ioutils.FprintfIfNotEmpty(cli.out, "Kernel Version: %s\n", info.KernelVersion)
|
ioutils.FprintfIfNotEmpty(cli.out, "Kernel Version: %s\n", info.KernelVersion)
|
||||||
ioutils.FprintfIfNotEmpty(cli.out, "Operating System: %s\n", info.OperatingSystem)
|
ioutils.FprintfIfNotEmpty(cli.out, "Operating System: %s\n", info.OperatingSystem)
|
||||||
|
ioutils.FprintfIfNotEmpty(cli.out, "OSType: %s\n", info.OSType)
|
||||||
|
ioutils.FprintfIfNotEmpty(cli.out, "Architecture: %s\n", info.Architecture)
|
||||||
fmt.Fprintf(cli.out, "CPUs: %d\n", info.NCPU)
|
fmt.Fprintf(cli.out, "CPUs: %d\n", info.NCPU)
|
||||||
fmt.Fprintf(cli.out, "Total Memory: %s\n", units.BytesSize(float64(info.MemTotal)))
|
fmt.Fprintf(cli.out, "Total Memory: %s\n", units.BytesSize(float64(info.MemTotal)))
|
||||||
ioutils.FprintfIfNotEmpty(cli.out, "Name: %s\n", info.Name)
|
ioutils.FprintfIfNotEmpty(cli.out, "Name: %s\n", info.Name)
|
||||||
|
|
|
@ -208,6 +208,8 @@ type Info struct {
|
||||||
NEventsListener int
|
NEventsListener int
|
||||||
KernelVersion string
|
KernelVersion string
|
||||||
OperatingSystem string
|
OperatingSystem string
|
||||||
|
OSType string
|
||||||
|
Architecture string
|
||||||
IndexServerAddress string
|
IndexServerAddress string
|
||||||
RegistryConfig *registry.ServiceConfig
|
RegistryConfig *registry.ServiceConfig
|
||||||
InitSha1 string
|
InitSha1 string
|
||||||
|
|
|
@ -11,6 +11,7 @@ import (
|
||||||
"github.com/docker/docker/pkg/fileutils"
|
"github.com/docker/docker/pkg/fileutils"
|
||||||
"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/platform"
|
||||||
"github.com/docker/docker/pkg/sysinfo"
|
"github.com/docker/docker/pkg/sysinfo"
|
||||||
"github.com/docker/docker/pkg/system"
|
"github.com/docker/docker/pkg/system"
|
||||||
"github.com/docker/docker/registry"
|
"github.com/docker/docker/registry"
|
||||||
|
@ -77,6 +78,8 @@ func (daemon *Daemon) SystemInfo() (*types.Info, error) {
|
||||||
KernelVersion: kernelVersion,
|
KernelVersion: kernelVersion,
|
||||||
OperatingSystem: operatingSystem,
|
OperatingSystem: operatingSystem,
|
||||||
IndexServerAddress: registry.IndexServer,
|
IndexServerAddress: registry.IndexServer,
|
||||||
|
OSType: platform.OSType,
|
||||||
|
Architecture: platform.Architecture,
|
||||||
RegistryConfig: daemon.RegistryService.Config,
|
RegistryConfig: daemon.RegistryService.Config,
|
||||||
InitSha1: dockerversion.InitSHA1,
|
InitSha1: dockerversion.InitSHA1,
|
||||||
InitPath: initPath,
|
InitPath: initPath,
|
||||||
|
|
|
@ -1884,6 +1884,7 @@ Display system-wide information
|
||||||
Content-Type: application/json
|
Content-Type: application/json
|
||||||
|
|
||||||
{
|
{
|
||||||
|
"Architecture": "x86_64",
|
||||||
"Containers": 11,
|
"Containers": 11,
|
||||||
"CpuCfsPeriod": true,
|
"CpuCfsPeriod": true,
|
||||||
"CpuCfsQuota": true,
|
"CpuCfsQuota": true,
|
||||||
|
@ -1915,6 +1916,7 @@ Display system-wide information
|
||||||
"Name": "prod-server-42",
|
"Name": "prod-server-42",
|
||||||
"NoProxy": "9.81.1.160",
|
"NoProxy": "9.81.1.160",
|
||||||
"OomKillDisable": true,
|
"OomKillDisable": true,
|
||||||
|
"OSType": "linux",
|
||||||
"OperatingSystem": "Boot2Docker",
|
"OperatingSystem": "Boot2Docker",
|
||||||
"RegistryConfig": {
|
"RegistryConfig": {
|
||||||
"IndexConfigs": {
|
"IndexConfigs": {
|
||||||
|
|
|
@ -31,6 +31,8 @@ For example:
|
||||||
Execution Driver: native-0.2
|
Execution Driver: native-0.2
|
||||||
Logging Driver: json-file
|
Logging Driver: json-file
|
||||||
Kernel Version: 3.19.0-22-generic
|
Kernel Version: 3.19.0-22-generic
|
||||||
|
OSType: linux
|
||||||
|
Architecture: x86_64
|
||||||
Operating System: Ubuntu 15.04
|
Operating System: Ubuntu 15.04
|
||||||
CPUs: 24
|
CPUs: 24
|
||||||
Total Memory: 62.86 GiB
|
Total Memory: 62.86 GiB
|
||||||
|
|
|
@ -23,6 +23,8 @@ func (s *DockerSuite) TestInfoApi(c *check.C) {
|
||||||
"LoggingDriver",
|
"LoggingDriver",
|
||||||
"OperatingSystem",
|
"OperatingSystem",
|
||||||
"NCPU",
|
"NCPU",
|
||||||
|
"OSType",
|
||||||
|
"Architecture",
|
||||||
"MemTotal",
|
"MemTotal",
|
||||||
"KernelVersion",
|
"KernelVersion",
|
||||||
"Driver",
|
"Driver",
|
||||||
|
|
|
@ -19,6 +19,8 @@ func (s *DockerSuite) TestInfoEnsureSucceeds(c *check.C) {
|
||||||
"Containers:",
|
"Containers:",
|
||||||
"Images:",
|
"Images:",
|
||||||
"Execution Driver:",
|
"Execution Driver:",
|
||||||
|
"OSType:",
|
||||||
|
"Architecture:",
|
||||||
"Logging Driver:",
|
"Logging Driver:",
|
||||||
"Operating System:",
|
"Operating System:",
|
||||||
"CPUs:",
|
"CPUs:",
|
||||||
|
|
|
@ -44,6 +44,8 @@ Here is a sample output:
|
||||||
Network: bridge null host
|
Network: bridge null host
|
||||||
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
|
||||||
|
OSType: linux
|
||||||
|
Architecture: x86_64
|
||||||
CPUs: 1
|
CPUs: 1
|
||||||
Total Memory: 2 GiB
|
Total Memory: 2 GiB
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,15 @@
|
||||||
|
package platform
|
||||||
|
|
||||||
|
import (
|
||||||
|
"os/exec"
|
||||||
|
)
|
||||||
|
|
||||||
|
// GetRuntimeArchitecture get the name of the current architecture (x86, x86_64, …)
|
||||||
|
func GetRuntimeArchitecture() (string, error) {
|
||||||
|
cmd := exec.Command("uname", "-m")
|
||||||
|
machine, err := cmd.Output()
|
||||||
|
if err != nil {
|
||||||
|
return "", err
|
||||||
|
}
|
||||||
|
return string(machine), nil
|
||||||
|
}
|
|
@ -0,0 +1,28 @@
|
||||||
|
// Package platform provides helper function to get the runtime architecture
|
||||||
|
// for different platforms.
|
||||||
|
package platform
|
||||||
|
|
||||||
|
import (
|
||||||
|
"syscall"
|
||||||
|
)
|
||||||
|
|
||||||
|
// GetRuntimeArchitecture get the name of the current architecture (x86, x86_64, …)
|
||||||
|
func GetRuntimeArchitecture() (string, error) {
|
||||||
|
utsname := &syscall.Utsname{}
|
||||||
|
if err := syscall.Uname(utsname); err != nil {
|
||||||
|
return "", err
|
||||||
|
}
|
||||||
|
return charsToString(utsname.Machine), nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func charsToString(ca [65]int8) string {
|
||||||
|
s := make([]byte, len(ca))
|
||||||
|
var lens int
|
||||||
|
for ; lens < len(ca); lens++ {
|
||||||
|
if ca[lens] == 0 {
|
||||||
|
break
|
||||||
|
}
|
||||||
|
s[lens] = uint8(ca[lens])
|
||||||
|
}
|
||||||
|
return string(s[0:lens])
|
||||||
|
}
|
|
@ -0,0 +1,52 @@
|
||||||
|
package platform
|
||||||
|
|
||||||
|
import (
|
||||||
|
"fmt"
|
||||||
|
"syscall"
|
||||||
|
"unsafe"
|
||||||
|
)
|
||||||
|
|
||||||
|
var (
|
||||||
|
modkernel32 = syscall.NewLazyDLL("kernel32.dll")
|
||||||
|
procGetSystemInfo = modkernel32.NewProc("GetSystemInfo")
|
||||||
|
)
|
||||||
|
|
||||||
|
// see http://msdn.microsoft.com/en-us/library/windows/desktop/ms724958(v=vs.85).aspx
|
||||||
|
type systeminfo struct {
|
||||||
|
wProcessorArchitecture uint16
|
||||||
|
wReserved uint16
|
||||||
|
dwPageSize uint32
|
||||||
|
lpMinimumApplicationAddress uintptr
|
||||||
|
lpMaximumApplicationAddress uintptr
|
||||||
|
dwActiveProcessorMask uintptr
|
||||||
|
dwNumberOfProcessors uint32
|
||||||
|
dwProcessorType uint32
|
||||||
|
dwAllocationGranularity uint32
|
||||||
|
wProcessorLevel uint16
|
||||||
|
wProcessorRevision uint16
|
||||||
|
}
|
||||||
|
|
||||||
|
// Constants
|
||||||
|
const (
|
||||||
|
ProcessorArchitecture64 = 9 // PROCESSOR_ARCHITECTURE_AMD64
|
||||||
|
ProcessorArchitectureIA64 = 6 // PROCESSOR_ARCHITECTURE_IA64
|
||||||
|
ProcessorArchitecture32 = 0 // PROCESSOR_ARCHITECTURE_INTEL
|
||||||
|
ProcessorArchitectureArm = 5 // PROCESSOR_ARCHITECTURE_ARM
|
||||||
|
)
|
||||||
|
|
||||||
|
var sysinfo systeminfo
|
||||||
|
|
||||||
|
// GetRuntimeArchitecture get the name of the current architecture (x86, x86_64, …)
|
||||||
|
func GetRuntimeArchitecture() (string, error) {
|
||||||
|
syscall.Syscall(procGetSystemInfo.Addr(), 1, uintptr(unsafe.Pointer(&sysinfo)), 0, 0)
|
||||||
|
switch sysinfo.wProcessorArchitecture {
|
||||||
|
case ProcessorArchitecture64, ProcessorArchitectureIA64:
|
||||||
|
return "x86_64", nil
|
||||||
|
case ProcessorArchitecture32:
|
||||||
|
return "i686", nil
|
||||||
|
case ProcessorArchitectureArm:
|
||||||
|
return "arm", nil
|
||||||
|
default:
|
||||||
|
return "", fmt.Errorf("Unknown processor architecture")
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,23 @@
|
||||||
|
package platform
|
||||||
|
|
||||||
|
import (
|
||||||
|
"runtime"
|
||||||
|
|
||||||
|
"github.com/Sirupsen/logrus"
|
||||||
|
)
|
||||||
|
|
||||||
|
var (
|
||||||
|
// Architecture holds the runtime architecture of the process.
|
||||||
|
Architecture string
|
||||||
|
// OSType holds the runtime operating system type (Linux, …) of the process.
|
||||||
|
OSType string
|
||||||
|
)
|
||||||
|
|
||||||
|
func init() {
|
||||||
|
var err error
|
||||||
|
Architecture, err = GetRuntimeArchitecture()
|
||||||
|
if err != nil {
|
||||||
|
logrus.Errorf("Could no read system architecture info: %v", err)
|
||||||
|
}
|
||||||
|
OSType = runtime.GOOS
|
||||||
|
}
|
Loading…
Reference in New Issue