Skip to content

Commit

Permalink
Add pagefault data to procstat input plugin (influxdata#5769)
Browse files Browse the repository at this point in the history
  • Loading branch information
sgtsquiggs authored and bitcharmer committed Oct 18, 2019
1 parent a26635c commit 00c6d31
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 0 deletions.
4 changes: 4 additions & 0 deletions plugins/inputs/procstat/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,8 @@ implemented as a WMI query. The pattern allows fuzzy matching using only
- cgroup (when defined)
- win_service (when defined)
- fields:
- child_major_faults (int)
- child_minor_faults (int)
- cpu_time (int)
- cpu_time_guest (float)
- cpu_time_guest_nice (float)
Expand All @@ -99,12 +101,14 @@ implemented as a WMI query. The pattern allows fuzzy matching using only
- cpu_time_user (float)
- cpu_usage (float)
- involuntary_context_switches (int)
- major_faults (int)
- memory_data (int)
- memory_locked (int)
- memory_rss (int)
- memory_stack (int)
- memory_swap (int)
- memory_vms (int)
- minor_faults (int)
- nice_priority (int)
- num_fds (int, *telegraf* may need to be ran as **root**)
- num_threads (int)
Expand Down
1 change: 1 addition & 0 deletions plugins/inputs/procstat/process.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ type Process interface {
PID() PID
Tags() map[string]string

PageFaults() (*process.PageFaultsStat, error)
IOCounters() (*process.IOCountersStat, error)
MemoryInfo() (*process.MemoryInfoStat, error)
Name() (string, error)
Expand Down
8 changes: 8 additions & 0 deletions plugins/inputs/procstat/procstat.go
Original file line number Diff line number Diff line change
Expand Up @@ -200,6 +200,14 @@ func (p *Procstat) addMetric(proc Process, acc telegraf.Accumulator) {
fields[prefix+"involuntary_context_switches"] = ctx.Involuntary
}

faults, err := proc.PageFaults()
if err == nil {
fields[prefix+"minor_faults"] = faults.MinorFaults
fields[prefix+"major_faults"] = faults.MajorFaults
fields[prefix+"child_minor_faults"] = faults.ChildMinorFaults
fields[prefix+"child_major_faults"] = faults.ChildMajorFaults
}

io, err := proc.IOCounters()
if err == nil {
fields[prefix+"read_count"] = io.ReadCount
Expand Down
4 changes: 4 additions & 0 deletions plugins/inputs/procstat/procstat_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,10 @@ func (p *testProc) Tags() map[string]string {
return p.tags
}

func (p *testProc) PageFaults() (*process.PageFaultsStat, error) {
return &process.PageFaultsStat{}, nil
}

func (p *testProc) IOCounters() (*process.IOCountersStat, error) {
return &process.IOCountersStat{}, nil
}
Expand Down

0 comments on commit 00c6d31

Please sign in to comment.