Add pagefault data to procstat input plugin (#5769)

This commit is contained in:
Matthew Crenshaw 2019-04-25 20:21:02 -04:00 committed by Daniel Nelson
parent 10b2a3de30
commit 9c3af1e6ac
4 changed files with 17 additions and 0 deletions

View File

@ -85,6 +85,8 @@ implemented as a WMI query. The pattern allows fuzzy matching using only
- cgroup (when defined) - cgroup (when defined)
- win_service (when defined) - win_service (when defined)
- fields: - fields:
- child_major_faults (int)
- child_minor_faults (int)
- cpu_time (int) - cpu_time (int)
- cpu_time_guest (float) - cpu_time_guest (float)
- cpu_time_guest_nice (float) - cpu_time_guest_nice (float)
@ -99,12 +101,14 @@ implemented as a WMI query. The pattern allows fuzzy matching using only
- cpu_time_user (float) - cpu_time_user (float)
- cpu_usage (float) - cpu_usage (float)
- involuntary_context_switches (int) - involuntary_context_switches (int)
- major_faults (int)
- memory_data (int) - memory_data (int)
- memory_locked (int) - memory_locked (int)
- memory_rss (int) - memory_rss (int)
- memory_stack (int) - memory_stack (int)
- memory_swap (int) - memory_swap (int)
- memory_vms (int) - memory_vms (int)
- minor_faults (int)
- nice_priority (int) - nice_priority (int)
- num_fds (int, *telegraf* may need to be ran as **root**) - num_fds (int, *telegraf* may need to be ran as **root**)
- num_threads (int) - num_threads (int)

View File

@ -12,6 +12,7 @@ type Process interface {
PID() PID PID() PID
Tags() map[string]string Tags() map[string]string
PageFaults() (*process.PageFaultsStat, error)
IOCounters() (*process.IOCountersStat, error) IOCounters() (*process.IOCountersStat, error)
MemoryInfo() (*process.MemoryInfoStat, error) MemoryInfo() (*process.MemoryInfoStat, error)
Name() (string, error) Name() (string, error)

View File

@ -200,6 +200,14 @@ func (p *Procstat) addMetric(proc Process, acc telegraf.Accumulator) {
fields[prefix+"involuntary_context_switches"] = ctx.Involuntary 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() io, err := proc.IOCounters()
if err == nil { if err == nil {
fields[prefix+"read_count"] = io.ReadCount fields[prefix+"read_count"] = io.ReadCount

View File

@ -116,6 +116,10 @@ func (p *testProc) Tags() map[string]string {
return p.tags return p.tags
} }
func (p *testProc) PageFaults() (*process.PageFaultsStat, error) {
return &process.PageFaultsStat{}, nil
}
func (p *testProc) IOCounters() (*process.IOCountersStat, error) { func (p *testProc) IOCounters() (*process.IOCountersStat, error) {
return &process.IOCountersStat{}, nil return &process.IOCountersStat{}, nil
} }