Skip to content

Commit

Permalink
Fix panic in cgroups monitoring (#21355)
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 #21113
  • Loading branch information
adriansr authored Sep 29, 2020
1 parent b65b123 commit 27e8bd3
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 27e8bd3

Please sign in to comment.