feat(inputs.procstat): Add status field (#13505)
This commit is contained in:
parent
adf12c6c4c
commit
f2a1101581
|
|
@ -124,6 +124,7 @@ the `win_perf_counters` input plugin as a more mature alternative.
|
|||
- num_threads (int)
|
||||
- pid (int)
|
||||
- ppid (int)
|
||||
- status (string)
|
||||
- read_bytes (int, *telegraf* may need to be ran as **root**)
|
||||
- read_count (int, *telegraf* may need to be ran as **root**)
|
||||
- realtime_priority (int)
|
||||
|
|
|
|||
|
|
@ -28,6 +28,7 @@ type Process interface {
|
|||
Username() (string, error)
|
||||
CreateTime() (int64, error)
|
||||
Ppid() (int32, error)
|
||||
Status() ([]string, error)
|
||||
}
|
||||
|
||||
type PIDFinder interface {
|
||||
|
|
|
|||
|
|
@ -284,6 +284,11 @@ func (p *Procstat) addMetric(proc Process, acc telegraf.Accumulator, t time.Time
|
|||
fields[prefix+"ppid"] = ppid
|
||||
}
|
||||
|
||||
status, err := proc.Status()
|
||||
if err == nil {
|
||||
fields[prefix+"status"] = status[0]
|
||||
}
|
||||
|
||||
acc.AddFields("procstat", fields, proc.Tags(), t)
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -169,6 +169,10 @@ func (p *testProc) Ppid() (int32, error) {
|
|||
return 0, nil
|
||||
}
|
||||
|
||||
func (p *testProc) Status() ([]string, error) {
|
||||
return []string{"running"}, nil
|
||||
}
|
||||
|
||||
var pid = PID(42)
|
||||
var exe = "foo"
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue