Skip to content

Commit 00c6d31

Browse files
sgtsquiggsbitcharmer
authored andcommitted
Add pagefault data to procstat input plugin (influxdata#5769)
1 parent a26635c commit 00c6d31

File tree

4 files changed

+17
-0
lines changed

4 files changed

+17
-0
lines changed

plugins/inputs/procstat/README.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,8 @@ implemented as a WMI query. The pattern allows fuzzy matching using only
8585
- cgroup (when defined)
8686
- win_service (when defined)
8787
- fields:
88+
- child_major_faults (int)
89+
- child_minor_faults (int)
8890
- cpu_time (int)
8991
- cpu_time_guest (float)
9092
- cpu_time_guest_nice (float)
@@ -99,12 +101,14 @@ implemented as a WMI query. The pattern allows fuzzy matching using only
99101
- cpu_time_user (float)
100102
- cpu_usage (float)
101103
- involuntary_context_switches (int)
104+
- major_faults (int)
102105
- memory_data (int)
103106
- memory_locked (int)
104107
- memory_rss (int)
105108
- memory_stack (int)
106109
- memory_swap (int)
107110
- memory_vms (int)
111+
- minor_faults (int)
108112
- nice_priority (int)
109113
- num_fds (int, *telegraf* may need to be ran as **root**)
110114
- num_threads (int)

plugins/inputs/procstat/process.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ type Process interface {
1212
PID() PID
1313
Tags() map[string]string
1414

15+
PageFaults() (*process.PageFaultsStat, error)
1516
IOCounters() (*process.IOCountersStat, error)
1617
MemoryInfo() (*process.MemoryInfoStat, error)
1718
Name() (string, error)

plugins/inputs/procstat/procstat.go

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -200,6 +200,14 @@ func (p *Procstat) addMetric(proc Process, acc telegraf.Accumulator) {
200200
fields[prefix+"involuntary_context_switches"] = ctx.Involuntary
201201
}
202202

203+
faults, err := proc.PageFaults()
204+
if err == nil {
205+
fields[prefix+"minor_faults"] = faults.MinorFaults
206+
fields[prefix+"major_faults"] = faults.MajorFaults
207+
fields[prefix+"child_minor_faults"] = faults.ChildMinorFaults
208+
fields[prefix+"child_major_faults"] = faults.ChildMajorFaults
209+
}
210+
203211
io, err := proc.IOCounters()
204212
if err == nil {
205213
fields[prefix+"read_count"] = io.ReadCount

plugins/inputs/procstat/procstat_test.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,10 @@ func (p *testProc) Tags() map[string]string {
116116
return p.tags
117117
}
118118

119+
func (p *testProc) PageFaults() (*process.PageFaultsStat, error) {
120+
return &process.PageFaultsStat{}, nil
121+
}
122+
119123
func (p *testProc) IOCounters() (*process.IOCountersStat, error) {
120124
return &process.IOCountersStat{}, nil
121125
}

0 commit comments

Comments
 (0)