1
0
Fork 0
mirror of https://github.com/moby/moby.git synced 2022-11-09 12:21:53 -05:00
moby--moby/daemon/stats
Ian Campbell 115f91d757 Correct CPU usage calculation in presence of offline CPUs and newer Linux
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>
2017-03-10 10:24:33 +00:00
..
collector.go Correct CPU usage calculation in presence of offline CPUs and newer Linux 2017-03-10 10:24:33 +00:00
collector_solaris.go Extract daemon statsCollector to its own package 2017-01-04 18:18:30 +01:00
collector_unix.go Correct CPU usage calculation in presence of offline CPUs and newer Linux 2017-03-10 10:24:33 +00:00
collector_windows.go Correct CPU usage calculation in presence of offline CPUs and newer Linux 2017-03-10 10:24:33 +00:00
types.go Extract daemon statsCollector to its own package 2017-01-04 18:18:30 +01:00