mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-06-19 21:31:37 +00:00
metrics: fix the panic for reading empty cpu stats (#21864)
This commit is contained in:
parent
bf4b42a551
commit
d4f1b8a6dd
1 changed files with 4 additions and 0 deletions
|
|
@ -32,6 +32,10 @@ func ReadCPUStats(stats *CPUStats) {
|
|||
log.Error("Could not read cpu stats", "err", err)
|
||||
return
|
||||
}
|
||||
if len(timeStats) == 0 {
|
||||
log.Error("Empty cpu stats")
|
||||
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) * cpu.ClocksPerSec)
|
||||
|
|
|
|||
Loading…
Reference in a new issue