Add process created_at time to procstat input (#7039)

This commit is contained in:
prashanthjbabu
2020-02-20 01:27:07 +05:30
committed by GitHub
parent 740e30a96d
commit 59a506ae4a
4 changed files with 13 additions and 2 deletions

View File

@@ -216,6 +216,11 @@ func (p *Procstat) addMetric(proc Process, acc telegraf.Accumulator) {
fields[prefix+"write_bytes"] = io.WriteBytes
}
createdAt, err := proc.CreateTime() //Returns epoch in ms
if err == nil {
fields[prefix+"created_at"] = createdAt * 1000000 //Convert ms to ns
}
cpu_time, err := proc.Times()
if err == nil {
fields[prefix+"cpu_time_user"] = cpu_time.User