mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-05-16 13:06:40 +00:00
metrics: fix the panic for reading empty cpu stats (#21864)
This commit is contained in:
parent
23524f8900
commit
b9ff57c59e
1 changed files with 4 additions and 0 deletions
|
|
@ -31,6 +31,10 @@ func ReadCPUStats(stats *CPUStats) {
|
||||||
log.Error("Could not read cpu stats", "err", err)
|
log.Error("Could not read cpu stats", "err", err)
|
||||||
return
|
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
|
// requesting all cpu times will always return an array with only one time stats entry
|
||||||
timeStat := timeStats[0]
|
timeStat := timeStats[0]
|
||||||
stats.GlobalTime = int64((timeStat.User + timeStat.Nice + timeStat.System) * cpu.ClocksPerSec)
|
stats.GlobalTime = int64((timeStat.User + timeStat.Nice + timeStat.System) * cpu.ClocksPerSec)
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue