From a005bc2100480320b33a650d1e9b829c610f4d6f Mon Sep 17 00:00:00 2001 From: Anton Kolesnikov Date: Fri, 6 Aug 2021 19:07:01 +0200 Subject: [PATCH] Fix CPU check On Linux, if there are no file descriptors available, the call returns an empty slice, which results in server crash. --- pkg/util/debug/cpu.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkg/util/debug/cpu.go b/pkg/util/debug/cpu.go index 5f7cf1bd66..4e3d88fc1b 100644 --- a/pkg/util/debug/cpu.go +++ b/pkg/util/debug/cpu.go @@ -8,7 +8,7 @@ import ( func CPUUsage(interval time.Duration) map[string]interface{} { cpuVal, err := cpu.Percent(interval, false) - if err != nil { + if err != nil || len(cpuVal) == 0 { return map[string]interface{}{} }