From feb6f4cbe09b2e5c1a83dac587095112a762c9ed Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=98=AD?= <81747598+lan-yonghui@users.noreply.github.com> Date: Thu, 5 Sep 2024 16:39:48 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E6=A6=82=E8=A7=88=E9=A1=B5=E8=8E=B7?= =?UTF-8?q?=E5=8F=96=20CPU=20=E7=B2=BE=E5=BA=A6=E9=97=AE=E9=A2=98=20(#6380?= =?UTF-8?q?)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Refs #6309 --- backend/app/service/dashboard.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/backend/app/service/dashboard.go b/backend/app/service/dashboard.go index a5cd0d8ab..b83efb984 100644 --- a/backend/app/service/dashboard.go +++ b/backend/app/service/dashboard.go @@ -151,12 +151,12 @@ func (u *DashboardService) LoadCurrentInfo(ioOption string, netOption string) *d currentInfo.Procs = hostInfo.Procs currentInfo.CPUTotal, _ = cpu.Counts(true) - totalPercent, _ := cpu.Percent(0, false) + totalPercent, _ := cpu.Percent(1*time.Second, false) if len(totalPercent) == 1 { currentInfo.CPUUsedPercent = totalPercent[0] currentInfo.CPUUsed = currentInfo.CPUUsedPercent * 0.01 * float64(currentInfo.CPUTotal) } - currentInfo.CPUPercent, _ = cpu.Percent(0, true) + currentInfo.CPUPercent, _ = cpu.Percent(1*time.Second, true) loadInfo, _ := load.Avg() currentInfo.Load1 = loadInfo.Load1