From 795ea49093ba9ed9032d6a2a77624f8296a64b6a Mon Sep 17 00:00:00 2001 From: Cameron Sparr Date: Wed, 7 Oct 2015 11:42:50 -0600 Subject: [PATCH] Add pid tag to procstat plugin, dont exit on error, only log --- plugins/procstat/spec_processor.go | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) diff --git a/plugins/procstat/spec_processor.go b/plugins/procstat/spec_processor.go index 81d5fdfa7..baff10994 100644 --- a/plugins/procstat/spec_processor.go +++ b/plugins/procstat/spec_processor.go @@ -2,6 +2,7 @@ package procstat import ( "fmt" + "log" "github.com/shirou/gopsutil/process" @@ -19,10 +20,16 @@ func (p *SpecProcessor) add(metric string, value interface{}) { p.acc.Add(p.Prefix+"_"+metric, value, p.tags) } -func NewSpecProcessor(prefix string, acc plugins.Accumulator, p *process.Process) *SpecProcessor { +func NewSpecProcessor( + prefix string, + acc plugins.Accumulator, + p *process.Process, +) *SpecProcessor { + tags := make(map[string]string) + tags["pid"] = fmt.Sprintf("%v", p.Pid) return &SpecProcessor{ Prefix: prefix, - tags: map[string]string{}, + tags: tags, acc: acc, proc: p, } @@ -30,19 +37,19 @@ func NewSpecProcessor(prefix string, acc plugins.Accumulator, p *process.Process func (p *SpecProcessor) pushMetrics() error { if err := p.pushFDStats(); err != nil { - return err + log.Printf(err.Error()) } if err := p.pushCtxStats(); err != nil { - return err + log.Printf(err.Error()) } if err := p.pushIOStats(); err != nil { - return err + log.Printf(err.Error()) } if err := p.pushCPUStats(); err != nil { - return err + log.Printf(err.Error()) } if err := p.pushMemoryStats(); err != nil { - return err + log.Printf(err.Error()) } return nil }