fix the bug: cpu percent will extremely high

Signed-off-by: Chao Deng <sheldon.d1018@gmail.com>
Upstream-commit: e222c61594e86e3c4728e6ba65ce8762fd640bd8
Component: engine
This commit is contained in:
RyanDeng
2015-11-02 14:51:05 +08:00
committed by Chao Deng
parent 885e606af9
commit 31b5bfbd70

View File

@ -206,9 +206,9 @@ func calculateCPUPercent(previousCPU, previousSystem uint64, v *types.StatsJSON)
var (
cpuPercent = 0.0
// calculate the change for the cpu usage of the container in between readings
cpuDelta = float64(v.CPUStats.CPUUsage.TotalUsage - previousCPU)
cpuDelta = float64(v.CPUStats.CPUUsage.TotalUsage) - float64(previousCPU)
// calculate the change for the entire system between readings
systemDelta = float64(v.CPUStats.SystemUsage - previousSystem)
systemDelta = float64(v.CPUStats.SystemUsage) - float64(previousSystem)
)
if systemDelta > 0.0 && cpuDelta > 0.0 {