Skip to content

Commit 205fa29

Browse files
authored
fix: refine CPU usage calculation in getLinuxSysInfo by removing unnecessary CPU count dependency
1 parent d1d8290 commit 205fa29

File tree

1 file changed

+2
-3
lines changed

1 file changed

+2
-3
lines changed

internal/master.go

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -934,9 +934,8 @@ func getLinuxSysInfo() SystemInfo {
934934
idle1, total1 := readStat()
935935
time.Sleep(baseDuration)
936936
idle2, total2 := readStat()
937-
numCPU := runtime.NumCPU()
938-
if deltaIdle, deltaTotal := idle2-idle1, total2-total1; deltaTotal > 0 && numCPU > 0 {
939-
info.CPU = min(int((deltaTotal-deltaIdle)*100/deltaTotal/uint64(numCPU)), 100)
937+
if deltaIdle, deltaTotal := idle2-idle1, total2-total1; deltaTotal > 0 {
938+
info.CPU = min(int((deltaTotal-deltaIdle)*100/deltaTotal), 100)
940939
}
941940

942941
// RAM占用:解析/proc/meminfo

0 commit comments

Comments
 (0)