Skip to content

Commit

Permalink
fix libbeat code I broke
Browse files Browse the repository at this point in the history
  • Loading branch information
fearful-symmetry committed Aug 11, 2021
1 parent b2ccbf1 commit eeda969
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 7 deletions.
15 changes: 9 additions & 6 deletions libbeat/metric/system/process/process.go
Original file line number Diff line number Diff line change
Expand Up @@ -372,7 +372,7 @@ func (procStats *Stats) getProcessEvent(process *Process) common.MapStr {
}
}

if procStats.EnableCgroups {
if procStats.EnableCgroups && process.RawStats != nil {
statsMap, err := process.RawStats.Format()
if err != nil {
procStats.logger.Warnf("Getting memory details: %v", err)
Expand Down Expand Up @@ -539,22 +539,25 @@ func (procStats *Stats) getSingleProcess(pid int, newProcs ProcsMap) *Process {

if !procStats.matchProcess(process.Name) {
logger.Debugf("Process name does not matches the provided regex; pid=%d; name=%s; err=", pid, process.Name, err)
return nil
}

err = process.getDetails(procStats.isWhitelistedEnvVar)
if err != nil {
logger.Debugf("Error getting details for process %s with pid=%d; err=%s", process.Name, process.Pid, err)
return nil
}

if procStats.EnableCgroups {
cgStats, err := procStats.cgroups.GetStatsForPid(pid)
if err != nil {
logger.Debugf("Error fetching cgroup data for process %s with pid=%d; err=%s", process.Name, process.Pid, err)
}
process.RawStats = cgStats
last := procStats.ProcsMap[process.Pid]
if last != nil {
process.RawStats.FillPercentages(last.RawStats, process.SampleTime, last.SampleTime)
} else {
process.RawStats = cgStats
last := procStats.ProcsMap[process.Pid]
if last != nil {
process.RawStats.FillPercentages(last.RawStats, process.SampleTime, last.SampleTime)
}
}

}
Expand Down
1 change: 0 additions & 1 deletion metricbeat/module/system/process/process.go
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,6 @@ func New(base mb.BaseMetricSet) (mb.MetricSet, error) {
if err != nil {
return nil, err
}

return m, nil
}

Expand Down

0 comments on commit eeda969

Please sign in to comment.