Commit Graph

3 Commits

Author SHA1 Message Date
6f5f3ec34f 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>
Upstream-commit: 115f91d7575d6de6c7781a96a082f144fd17e400
Component: engine
2017-03-10 10:24:33 +00:00
50715b9350 Send "Name" and "ID" when stating stopped containers
When `docker stats` stopped containers, client will get empty stats data,
this commit will gurantee client always get "Name" and "ID" field, so
that it can format with `ID` and `Name` fields successfully.

Signed-off-by: Zhang Wei <zhangwei555@huawei.com>
Upstream-commit: eb3a7c232908377f4d4c0b0ec6fd35b0be138fdd
Component: engine
2017-02-09 09:46:59 +08:00
22fd058892 Extract daemon statsCollector to its own package
Signed-off-by: Vincent Demeester <vincent@sbr.pm>
Upstream-commit: 835971c6fdaf6ea35a0e7e45f6d9a09fd5f03ce1
Component: engine
2017-01-04 18:18:30 +01:00