Skip to content

Commit

Permalink
Add system uptime metric, string formatted AND in float64
Browse files Browse the repository at this point in the history
closes #150
  • Loading branch information
sparrc committed Aug 31, 2015
1 parent e2bc5d8 commit 62e05ec
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 3 deletions.
3 changes: 2 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@

### Features

[#158](https://github.com/influxdb/telegraf/pull/158): Apache Plugin
[#155](https://github.com/influxdb/telegraf/pull/155): Add Host Uptime metric to system plugin
[#158](https://github.com/influxdb/telegraf/pull/158): Apache Plugin. Thanks @KPACHbIuLLIAnO4

### Bugfixes

Expand Down
14 changes: 12 additions & 2 deletions plugins/system/system.go
Original file line number Diff line number Diff line change
@@ -1,13 +1,17 @@
package system

import "github.com/influxdb/telegraf/plugins"
import (
"github.com/cloudfoundry/gosigar"

"github.com/influxdb/telegraf/plugins"
)

type SystemStats struct {
ps PS
}

func (_ *SystemStats) Description() string {
return "Read metrics about system load"
return "Read metrics about system load & uptime"
}

func (_ *SystemStats) SampleConfig() string { return "" }
Expand All @@ -21,13 +25,19 @@ func (s *SystemStats) add(acc plugins.Accumulator,

func (s *SystemStats) Gather(acc plugins.Accumulator) error {
lv, err := s.ps.LoadAvg()
uptime := sigar.Uptime{}
if err != nil {
return err
}
if err := uptime.Get(); err != nil {
return err
}

acc.Add("load1", lv.Load1, nil)
acc.Add("load5", lv.Load5, nil)
acc.Add("load15", lv.Load15, nil)
acc.Add("uptime", uptime.Length, nil)
acc.Add("uptime_format", uptime.Format(), nil)

return nil
}
Expand Down

0 comments on commit 62e05ec

Please sign in to comment.