Skip to content

Commit d3179fa

Browse files
committed
potential fix for difference in units between gosig and gopsutil
1 parent 490fdbd commit d3179fa

File tree

1 file changed

+8
-5
lines changed

1 file changed

+8
-5
lines changed

metrics/cpu_enabled.go

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,19 +18,22 @@
1818

1919
package metrics
2020

21-
import "github.com/shirou/gopsutil/cpu"
21+
import (
22+
"github.com/ethereum/go-ethereum/log"
23+
"github.com/shirou/gopsutil/cpu"
24+
)
2225

2326
// ReadCPUStats retrieves the current CPU stats.
2427
func ReadCPUStats(stats *CPUStats) {
2528
// passing false to request all cpu times
2629
timeStats, err := cpu.Times(false)
2730
if err != nil {
28-
return // TODO is it okay to just return if cpu.Times errors out? Or should it be a fatal error
31+
log.Error("Could not read cpu stats", "err", err)
32+
return
2933
}
3034
// requesting all cpu times will always return an array with only one time stats entry
3135
timeStat := timeStats[0]
32-
33-
stats.GlobalTime = int64(timeStat.User + timeStat.Nice + timeStat.System)
34-
stats.GlobalWait = int64(timeStat.Iowait)
36+
stats.GlobalTime = int64((timeStat.User + timeStat.Nice + timeStat.System)*128)
37+
stats.GlobalWait = int64((timeStat.Iowait)*128)
3538
stats.LocalTime = getProcessCPUTime()
3639
}

0 commit comments

Comments
 (0)