mirror of
https://github.com/moby/moby.git
synced 2022-11-09 12:21:53 -05:00
daemon: SystemInfo() extract collecting debugging information to a helper
This makes it more inline with other data we collect, and can be used to make some info optional at some point. fillDebugInfo sets the current debugging state of the daemon, and additional debugging information, such as the number of Go-routines, and file descriptors. Note that this currently always collects the information, but the CLI only prints it if the daemon has debug enabled. We should consider to either make this information optional (cli to request "with debugging information"), or only collect it if the daemon has debug enabled. For the CLI code, see https://github.com/docker/cli/blob/v20.10.12/cli/command/system/info.go#L239-L244 Additional note: the CLI considers info.SystemTime debugging information. This felt a bit "odd" (daemon time could be useful for standard use), so I left this out of this function. Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
This commit is contained in:
parent
ac2cd5a8f2
commit
d492101172
1 changed files with 16 additions and 4 deletions
|
@ -37,13 +37,9 @@ func (daemon *Daemon) SystemInfo() *types.Info {
|
|||
IPv4Forwarding: !sysInfo.IPv4ForwardingDisabled,
|
||||
BridgeNfIptables: !sysInfo.BridgeNFCallIPTablesDisabled,
|
||||
BridgeNfIP6tables: !sysInfo.BridgeNFCallIP6TablesDisabled,
|
||||
Debug: debug.IsEnabled(),
|
||||
Name: hostName(),
|
||||
NFd: fileutils.GetTotalUsedFds(),
|
||||
NGoroutines: runtime.NumGoroutine(),
|
||||
SystemTime: time.Now().Format(time.RFC3339Nano),
|
||||
LoggingDriver: daemon.defaultLogConfig.Type,
|
||||
NEventsListener: daemon.EventsService.SubscribersCount(),
|
||||
KernelVersion: kernelVersion(),
|
||||
OperatingSystem: operatingSystem(),
|
||||
OSVersion: osVersion(),
|
||||
|
@ -66,6 +62,7 @@ func (daemon *Daemon) SystemInfo() *types.Info {
|
|||
}
|
||||
|
||||
daemon.fillContainerStates(v)
|
||||
daemon.fillDebugInfo(v)
|
||||
daemon.fillAPIInfo(v)
|
||||
// Retrieve platform specific info
|
||||
daemon.fillPlatformInfo(v, sysInfo)
|
||||
|
@ -185,6 +182,21 @@ func (daemon *Daemon) fillContainerStates(v *types.Info) {
|
|||
v.ContainersStopped = cStopped
|
||||
}
|
||||
|
||||
// fillDebugInfo sets the current debugging state of the daemon, and additional
|
||||
// debugging information, such as the number of Go-routines, and file descriptors.
|
||||
//
|
||||
// Note that this currently always collects the information, but the CLI only
|
||||
// prints it if the daemon has debug enabled. We should consider to either make
|
||||
// this information optional (cli to request "with debugging information"), or
|
||||
// only collect it if the daemon has debug enabled. For the CLI code, see
|
||||
// https://github.com/docker/cli/blob/v20.10.12/cli/command/system/info.go#L239-L244
|
||||
func (daemon *Daemon) fillDebugInfo(v *types.Info) {
|
||||
v.Debug = debug.IsEnabled()
|
||||
v.NFd = fileutils.GetTotalUsedFds()
|
||||
v.NGoroutines = runtime.NumGoroutine()
|
||||
v.NEventsListener = daemon.EventsService.SubscribersCount()
|
||||
}
|
||||
|
||||
func (daemon *Daemon) fillAPIInfo(v *types.Info) {
|
||||
const warn string = `
|
||||
Access to the remote API is equivalent to root access on the host. Refer
|
||||
|
|
Loading…
Add table
Reference in a new issue