From d3179fad2372b2a615ba790d6c597bb500faac77 Mon Sep 17 00:00:00 2001 From: renaynay <41963722+renaynay@users.noreply.github.com> Date: Thu, 7 May 2020 21:33:35 +0200 Subject: [PATCH] potential fix for difference in units between gosig and gopsutil --- metrics/cpu_enabled.go | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/metrics/cpu_enabled.go b/metrics/cpu_enabled.go index 42c3cd96c8..e2963b598f 100644 --- a/metrics/cpu_enabled.go +++ b/metrics/cpu_enabled.go @@ -18,19 +18,22 @@ package metrics -import "github.com/shirou/gopsutil/cpu" +import ( + "github.com/ethereum/go-ethereum/log" + "github.com/shirou/gopsutil/cpu" +) // ReadCPUStats retrieves the current CPU stats. func ReadCPUStats(stats *CPUStats) { // passing false to request all cpu times timeStats, err := cpu.Times(false) if err != nil { - return // TODO is it okay to just return if cpu.Times errors out? Or should it be a fatal error + log.Error("Could not read cpu stats", "err", err) + return } // requesting all cpu times will always return an array with only one time stats entry timeStat := timeStats[0] - - stats.GlobalTime = int64(timeStat.User + timeStat.Nice + timeStat.System) - stats.GlobalWait = int64(timeStat.Iowait) + stats.GlobalTime = int64((timeStat.User + timeStat.Nice + timeStat.System)*128) + stats.GlobalWait = int64((timeStat.Iowait)*128) stats.LocalTime = getProcessCPUTime() }