115f91d757
In https://github.com/torvalds/linux/commit/5ca3726 (released in v4.7-rc1) the content of the `cpuacct.usage_percpu` file in sysfs was changed to include both online and offline cpus. This broke the arithmetic in the stats helpers used by `docker stats`, since it was using the length of the PerCPUUsage array as a proxy for the number of online CPUs. Add current number of online CPUs to types.StatsJSON and use it in the calculation. Keep a fallback to `len(v.CPUStats.CPUUsage.PercpuUsage)` so this code continues to work when talking to an older daemon. An old client talking to a new daemon will ignore the new field and behave as before. Fixes #28941. Signed-off-by: Ian Campbell <ian.campbell@docker.com>
19 lines
548 B
Go
19 lines
548 B
Go
// +build windows
|
|
|
|
package stats
|
|
|
|
// platformNewStatsCollector performs platform specific initialisation of the
|
|
// Collector structure. This is a no-op on Windows.
|
|
func platformNewStatsCollector(s *Collector) {
|
|
}
|
|
|
|
// getSystemCPUUsage returns the host system's cpu usage in
|
|
// nanoseconds. An error is returned if the format of the underlying
|
|
// file does not match. This is a no-op on Windows.
|
|
func (s *Collector) getSystemCPUUsage() (uint64, error) {
|
|
return 0, nil
|
|
}
|
|
|
|
func (s *Collector) getNumberOnlineCPUs() (uint32, error) {
|
|
return 0, nil
|
|
}
|