good morning!!!!

Skip to content
Snippets Groups Projects
Unverified Commit b9ff57c5 authored by Gary Rong's avatar Gary Rong Committed by GitHub
Browse files

metrics: fix the panic for reading empty cpu stats (#21864)

parent 23524f89
No related branches found
No related tags found
No related merge requests found
......@@ -31,6 +31,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)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment