Skip to content

Commit

Permalink
Fix panic in cgroups monitoring
Browse files Browse the repository at this point in the history
Gosigar's cgroups GetStatsForProcesses can return a nil Stats pointer
and no error when the ["blkio", "cpu", "cpuacct", "memory"] subsystems
are on the root cgroup.

Related elastic#21113
  • Loading branch information
adriansr committed Sep 28, 2020
1 parent ddfe085 commit 1a2af5c
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions libbeat/cmd/instance/metrics.go
Original file line number Diff line number Diff line change
Expand Up @@ -285,6 +285,10 @@ func reportBeatCgroups(_ monitoring.Mode, V monitoring.Visitor) {
logp.Err("error getting group status: %v", err)
return
}
// GetStatsForProcess returns a nil selfStats and no error when there's no stats
if selfStats == nil {
return
}

if cpu := selfStats.CPU; cpu != nil {
monitoring.ReportNamespace(V, "cpu", func() {
Expand Down

0 comments on commit 1a2af5c

Please sign in to comment.