telegraf/plugins/system/system.go

40 lines
745 B
Go
Raw Normal View History

package system
import "github.com/influxdb/telegraf/plugins"
type SystemStats struct {
ps PS
}
func (_ *SystemStats) Description() string {
return "Read metrics about system load"
}
func (_ *SystemStats) SampleConfig() string { return "" }
func (s *SystemStats) add(acc plugins.Accumulator,
name string, val float64, tags map[string]string) {
if val >= 0 {
acc.Add(name, val, tags)
}
}
func (s *SystemStats) Gather(acc plugins.Accumulator) error {
lv, err := s.ps.LoadAvg()
if err != nil {
return err
2015-04-06 23:03:09 +00:00
}
acc.Add("load1", lv.Load1, nil)
acc.Add("load5", lv.Load5, nil)
acc.Add("load15", lv.Load15, nil)
return nil
}
func init() {
plugins.Add("system", func() plugins.Plugin {
return &SystemStats{ps: &systemPS{}}
})
}