Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add running field to procstat_lookup #5069

Merged
merged 3 commits into from
Dec 12, 2018
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Add procstat lookup result information and always emit metric
  • Loading branch information
danielnelson committed Nov 30, 2018
commit 50c523a71ceb642c7514574bb6c0a7a480505072
21 changes: 12 additions & 9 deletions plugins/inputs/procstat/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -136,18 +136,21 @@ implemented as a WMI query. The pattern allows fuzzy matching using only
- write_count (int, *telegraf* may need to be ran as **root**)
- procstat_lookup
- tags:
- exe (string)
- pid_finder (string)
- pid_file (string)
- pattern (string)
- prefix (string)
- user (string)
- systemd_unit (string)
- cgroup (string)
- win_service (string)
- exe
- pid_finder
- pid_file
- pattern
- prefix
- user
- systemd_unit
- cgroup
- win_service
- result
- fields:
- pid_count (int)
- running (int)
- result_code (int, success = 0, lookup_error = 1)

*NOTE: Resource limit > 2147483647 will be reported as 2147483647.*

### Example Output:
Expand Down
14 changes: 12 additions & 2 deletions plugins/inputs/procstat/procstat.go
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,14 @@ func (p *Procstat) Gather(acc telegraf.Accumulator) error {

pids, tags, err := p.findPids(acc)
if err != nil {
fields := map[string]interface{}{
"pid_count": 0,
"running": 0,
"result_code": 1,
}
tags["pid_finder"] = p.PidFinder
tags["result"] = "lookup_error"
acc.AddFields("procstat_lookup", fields, tags)
return err
}

Expand All @@ -119,10 +127,12 @@ func (p *Procstat) Gather(acc telegraf.Accumulator) error {
}

fields := map[string]interface{}{
"pid_count": len(pids),
"running": len(procs),
"pid_count": len(pids),
"running": len(procs),
"result_code": 0,
}
tags["pid_finder"] = p.PidFinder
tags["result"] = "success"
acc.AddFields("procstat_lookup", fields, tags)

return nil
Expand Down