From 6860545ea3c5522752a6531cecdf8dfd9ced6740 Mon Sep 17 00:00:00 2001 From: Daniel Nelson Date: Tue, 21 Mar 2017 11:40:51 -0700 Subject: [PATCH] Really fix procstat initialization --- plugins/inputs/procstat/procstat.go | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/plugins/inputs/procstat/procstat.go b/plugins/inputs/procstat/procstat.go index 20c5af9d2..d689ecf3e 100644 --- a/plugins/inputs/procstat/procstat.go +++ b/plugins/inputs/procstat/procstat.go @@ -62,6 +62,13 @@ func (_ *Procstat) Description() string { } func (p *Procstat) Gather(acc telegraf.Accumulator) error { + if p.createPIDFinder == nil { + p.createPIDFinder = defaultPIDFinder + } + if p.createProcess == nil { + p.createProcess = defaultProcess + } + procs, err := p.updateProcesses(p.procs) if err != nil { return fmt.Errorf( @@ -235,9 +242,6 @@ func (p *Procstat) findPids() ([]PID, map[string]string, error) { func init() { inputs.Add("procstat", func() telegraf.Input { - return &Procstat{ - createPIDFinder: defaultPIDFinder, - createProcess: defaultProcess, - } + return &Procstat{} }) }