From 80838373336f4761ceaed15ca4fcd2d0023c54cf Mon Sep 17 00:00:00 2001 From: ssongliu <73214554+ssongliu@users.noreply.github.com> Date: Wed, 10 May 2023 14:48:15 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E5=AE=B9=E5=99=A8=E7=9B=91=E6=8E=A7?= =?UTF-8?q?=E9=80=82=E9=85=8D=E9=83=A8=E5=88=86=E5=8D=95=E6=A0=B8=E7=B3=BB?= =?UTF-8?q?=E7=BB=9F=20(#984)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- backend/app/service/container.go | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/backend/app/service/container.go b/backend/app/service/container.go index ca717abaa..4ee02b92f 100644 --- a/backend/app/service/container.go +++ b/backend/app/service/container.go @@ -326,7 +326,10 @@ func calculateCPUPercentUnix(stats *types.StatsJSON) float64 { systemDelta := float64(stats.CPUStats.SystemUsage) - float64(stats.PreCPUStats.SystemUsage) if systemDelta > 0.0 && cpuDelta > 0.0 { - cpuPercent = (cpuDelta / systemDelta) * float64(len(stats.CPUStats.CPUUsage.PercpuUsage)) * 100.0 + cpuPercent = (cpuDelta / systemDelta) * 100.0 + if len(stats.CPUStats.CPUUsage.PercpuUsage) != 0 { + cpuPercent = cpuPercent * float64(len(stats.CPUStats.CPUUsage.PercpuUsage)) + } } return cpuPercent }