Skip to content

Commit

Permalink
Fix CPU check
Browse files Browse the repository at this point in the history
On Linux, if there are no file descriptors available, the call
returns an empty slice, which results in server crash.
  • Loading branch information
kolesnikovae committed Aug 10, 2021
1 parent 153b95d commit a005bc2
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion pkg/util/debug/cpu.go
Original file line number Diff line number Diff line change
Expand Up @@ -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{}{}
}

Expand Down

0 comments on commit a005bc2

Please sign in to comment.