From 31b5bfbd709a67f296cedc944313aac39f11a97d Mon Sep 17 00:00:00 2001 From: RyanDeng Date: Mon, 2 Nov 2015 14:51:05 +0800 Subject: [PATCH] fix the bug: cpu percent will extremely high Signed-off-by: Chao Deng Upstream-commit: e222c61594e86e3c4728e6ba65ce8762fd640bd8 Component: engine --- components/engine/api/client/stats.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/components/engine/api/client/stats.go b/components/engine/api/client/stats.go index 360d132d3b..70dd6fef9c 100644 --- a/components/engine/api/client/stats.go +++ b/components/engine/api/client/stats.go @@ -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 {