94715e8e |
package daemon
import ( |
514ca094 |
"fmt" |
94715e8e |
"os"
"runtime" |
3aa4a007 |
"strings" |
2977fd2b |
"time" |
94715e8e |
|
d29995bb |
"github.com/docker/docker/api" |
91e197d6 |
"github.com/docker/docker/api/types" |
ce375503 |
"github.com/docker/docker/cli/debug" |
17abacb8 |
"github.com/docker/docker/daemon/logger" |
8054a303 |
"github.com/docker/docker/dockerversion" |
c30a55f1 |
"github.com/docker/docker/pkg/fileutils" |
94715e8e |
"github.com/docker/docker/pkg/parsers/kernel"
"github.com/docker/docker/pkg/parsers/operatingsystem" |
49779b67 |
"github.com/docker/docker/pkg/platform" |
b2d06b6f |
"github.com/docker/docker/pkg/sysinfo" |
61f8001c |
"github.com/docker/docker/pkg/system" |
94715e8e |
"github.com/docker/docker/registry" |
aa7fd884 |
"github.com/docker/docker/volume/drivers" |
05002c25 |
"github.com/docker/go-connections/sockets" |
1009e6a4 |
"github.com/sirupsen/logrus" |
94715e8e |
)
|
abd72d40 |
// SystemInfo returns information about the host server the daemon is running on. |
b08f071e |
func (daemon *Daemon) SystemInfo() (*types.Info, error) { |
94715e8e |
kernelVersion := "<unknown>" |
b0fb0f19 |
if kv, err := kernel.GetKernelVersion(); err != nil {
logrus.Warnf("Could not get kernel version: %v", err)
} else { |
94715e8e |
kernelVersion = kv.String()
}
operatingSystem := "<unknown>" |
b0fb0f19 |
if s, err := operatingsystem.GetOperatingSystem(); err != nil {
logrus.Warnf("Could not get operating system name: %v", err)
} else { |
94715e8e |
operatingSystem = s
} |
ab97303c |
// Don't do containerized check on Windows
if runtime.GOOS != "windows" {
if inContainer, err := operatingsystem.IsContainerized(); err != nil {
logrus.Errorf("Could not determine if daemon is containerized: %v", err)
operatingSystem += " (error determining if containerized)"
} else if inContainer {
operatingSystem += " (containerized)"
} |
94715e8e |
}
|
61f8001c |
meminfo, err := system.ReadMemInfo()
if err != nil { |
6f4d8470 |
logrus.Errorf("Could not read system memory info: %v", err) |
5f7b1b60 |
meminfo = &system.MemInfo{} |
61f8001c |
}
|
aaacde4f |
sysInfo := sysinfo.New(true) |
e4c03623 |
cRunning, cPaused, cStopped := stateCtr.get() |
e732f4e6 |
|
514ca094 |
securityOptions := []string{} |
190654aa |
if sysInfo.AppArmor { |
514ca094 |
securityOptions = append(securityOptions, "name=apparmor") |
190654aa |
} |
a3b9dd89 |
if sysInfo.Seccomp && supportsSeccomp { |
b237189e |
profile := daemon.seccompProfilePath
if profile == "" {
profile = "default"
} |
514ca094 |
securityOptions = append(securityOptions, fmt.Sprintf("name=seccomp,profile=%s", profile)) |
190654aa |
}
if selinuxEnabled() { |
514ca094 |
securityOptions = append(securityOptions, "name=selinux") |
190654aa |
} |
93fbdb69 |
rootIDs := daemon.idMappings.RootPair() |
09cd96c5 |
if rootIDs.UID != 0 || rootIDs.GID != 0 { |
514ca094 |
securityOptions = append(securityOptions, "name=userns") |
ae74092e |
} |
190654aa |
|
ce8e529e |
var ds [][2]string |
3aa4a007 |
drivers := "" |
ce8e529e |
for os, gd := range daemon.graphDrivers { |
afd305c4 |
ds = append(ds, daemon.layerStores[os].DriverStatus()...) |
ce8e529e |
drivers += gd
if len(daemon.graphDrivers) > 1 {
drivers += fmt.Sprintf(" (%s) ", os) |
3aa4a007 |
}
}
drivers = strings.TrimSpace(drivers) |
ce8e529e |
|
514ca094 |
v := &types.Info{ |
f4942ed8 |
ID: daemon.ID, |
2f5f0af3 |
Containers: cRunning + cPaused + cStopped,
ContainersRunning: cRunning,
ContainersPaused: cPaused,
ContainersStopped: cStopped, |
ce8e529e |
Images: len(daemon.imageStore.Map()), |
3aa4a007 |
Driver: drivers, |
ce8e529e |
DriverStatus: ds, |
aa7fd884 |
Plugins: daemon.showPluginsInfo(), |
b2d06b6f |
IPv4Forwarding: !sysInfo.IPv4ForwardingDisabled, |
5b3fc7aa |
BridgeNfIptables: !sysInfo.BridgeNFCallIPTablesDisabled,
BridgeNfIP6tables: !sysInfo.BridgeNFCallIP6TablesDisabled, |
ce375503 |
Debug: debug.IsEnabled(), |
f4942ed8 |
NFd: fileutils.GetTotalUsedFds(),
NGoroutines: runtime.NumGoroutine(),
SystemTime: time.Now().Format(time.RFC3339Nano),
LoggingDriver: daemon.defaultLogConfig.Type, |
ca89c329 |
CgroupDriver: daemon.getCgroupDriver(), |
f4942ed8 |
NEventsListener: daemon.EventsService.SubscribersCount(),
KernelVersion: kernelVersion,
OperatingSystem: operatingSystem, |
4fcb9ac4 |
IndexServerAddress: registry.IndexServer, |
49779b67 |
OSType: platform.OSType,
Architecture: platform.Architecture, |
59586d02 |
RegistryConfig: daemon.RegistryService.ServiceConfig(), |
8b2383f5 |
NCPU: sysinfo.NumCPU(), |
f4942ed8 |
MemTotal: meminfo.MemTotal, |
87e1464c |
GenericResources: daemon.genericResources, |
3662f580 |
DockerRootDir: daemon.configStore.Root,
Labels: daemon.configStore.Labels, |
7781a1bf |
ExperimentalBuild: daemon.configStore.Experimental, |
8054a303 |
ServerVersion: dockerversion.Version, |
3662f580 |
ClusterStore: daemon.configStore.ClusterStore,
ClusterAdvertise: daemon.configStore.ClusterAdvertise, |
05002c25 |
HTTPProxy: sockets.GetProxyEnv("http_proxy"),
HTTPSProxy: sockets.GetProxyEnv("https_proxy"),
NoProxy: sockets.GetProxyEnv("no_proxy"), |
189aaf8a |
LiveRestoreEnabled: daemon.configStore.LiveRestoreEnabled, |
514ca094 |
SecurityOptions: securityOptions, |
c4e16972 |
Isolation: daemon.defaultIsolation, |
f4942ed8 |
}
|
17df5593 |
// Retrieve platform specific info
daemon.FillPlatformInfo(v, sysInfo) |
4348ad68 |
|
a1c95091 |
hostname := ""
if hn, err := os.Hostname(); err != nil {
logrus.Warnf("Could not get hostname: %v", err)
} else {
hostname = hn |
9a85f60c |
} |
a1c95091 |
v.Name = hostname |
f4942ed8 |
|
514ca094 |
return v, nil |
94715e8e |
} |
aa7fd884 |
|
867f4329 |
// SystemVersion returns version information about the daemon.
func (daemon *Daemon) SystemVersion() types.Version { |
9152e632 |
kernelVersion := "<unknown>"
if kv, err := kernel.GetKernelVersion(); err != nil {
logrus.Warnf("Could not get kernel version: %v", err)
} else {
kernelVersion = kv.String()
}
|
867f4329 |
v := types.Version{ |
9152e632 |
Components: []types.ComponentVersion{
{
Name: "Engine",
Version: dockerversion.Version,
Details: map[string]string{
"GitCommit": dockerversion.GitCommit,
"ApiVersion": api.DefaultVersion,
"MinAPIVersion": api.MinVersion,
"GoVersion": runtime.Version(),
"Os": runtime.GOOS,
"Arch": runtime.GOARCH,
"BuildTime": dockerversion.BuildTime,
"KernelVersion": kernelVersion,
"Experimental": fmt.Sprintf("%t", daemon.configStore.Experimental),
},
},
},
// Populate deprecated fields for older clients |
d29995bb |
Version: dockerversion.Version,
GitCommit: dockerversion.GitCommit, |
9152e632 |
APIVersion: api.DefaultVersion, |
d29995bb |
MinAPIVersion: api.MinVersion,
GoVersion: runtime.Version(),
Os: runtime.GOOS,
Arch: runtime.GOARCH,
BuildTime: dockerversion.BuildTime, |
9152e632 |
KernelVersion: kernelVersion, |
d29995bb |
Experimental: daemon.configStore.Experimental, |
867f4329 |
}
|
9152e632 |
v.Platform.Name = dockerversion.PlatformName |
867f4329 |
return v
}
|
aa7fd884 |
func (daemon *Daemon) showPluginsInfo() types.PluginsInfo {
var pluginsInfo types.PluginsInfo
pluginsInfo.Volume = volumedrivers.GetDriverList() |
7ca635a1 |
pluginsInfo.Network = daemon.GetNetworkDriverList() |
cfcf2a0c |
// The authorization plugins are returned in the order they are
// used as they constitute a request/response modification chain.
pluginsInfo.Authorization = daemon.configStore.AuthorizationPlugins |
17abacb8 |
pluginsInfo.Log = logger.ListDrivers() |
4a1eb3f3 |
|
aa7fd884 |
return pluginsInfo
} |