telegraf/plugins/system/ps/load/load_freebsd.go

38 lines
630 B
Go
Raw Normal View History

2015-04-04 00:22:31 +00:00
// +build freebsd
package load
import (
"strconv"
2015-04-07 16:39:23 +00:00
common "github.com/influxdb/tivan/plugins/system/ps/common"
2015-04-04 00:22:31 +00:00
)
func LoadAvg() (*LoadAvgStat, error) {
values, err := common.DoSysctrl("vm.loadavg")
if err != nil {
return nil, err
}
load1, err := strconv.ParseFloat(values[0], 64)
if err != nil {
return nil, err
}
load5, err := strconv.ParseFloat(values[1], 64)
if err != nil {
return nil, err
}
load15, err := strconv.ParseFloat(values[2], 64)
if err != nil {
return nil, err
}
ret := &LoadAvgStat{
Load1: float64(load1),
Load5: float64(load5),
Load15: float64(load15),
}
return ret, nil
}