Skip to content

Commit

Permalink
fix: 概览页获取 CPU 精度问题
Browse files Browse the repository at this point in the history
fixed #6309
  • Loading branch information
lan-yonghui committed Sep 5, 2024
1 parent 1173bbf commit 2b49a7a
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions backend/app/service/dashboard.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 2b49a7a

Please # to comment.