未验证 提交 b9ff57c5 编写于 作者: G gary rong 提交者: GitHub

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

上级 23524f89
......@@ -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)
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册