From 2b49a7a8ccb82180a25e92ca3296253d3784dced Mon Sep 17 00:00:00 2001 From: lan-yonghui Date: Thu, 5 Sep 2024 16:36:54 +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=20fixed?= =?UTF-8?q?=20#6309?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- 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 a5cd0d8abfd3..b83efb9845ff 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