mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-08-20 10:52:25 +00:00
potential fix for difference in units between gosig and gopsutil
This commit is contained in:
parent
490fdbdff6
commit
d3179fad23
1 changed files with 8 additions and 5 deletions
|
|
@ -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()
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue