1
0
mirror of https://github.com/shirou/gopsutil.git synced 2025-04-26 13:48:59 +08:00
shirou_gopsutil/load_freebsd.go

36 lines
604 B
Go
Raw Normal View History

2014-04-18 16:34:47 +09:00
// +build freebsd
2014-04-22 09:44:22 +09:00
package gopsutil
2014-04-18 16:34:47 +09:00
import (
"strconv"
)
func LoadAvg() (LoadAvgStat, error) {
2014-04-22 12:43:31 +09:00
values, err := do_sysctrl("vm.loadavg")
2014-04-18 16:34:47 +09:00
if err != nil {
return LoadAvgStat{}, err
2014-04-18 16:34:47 +09:00
}
2014-04-22 10:12:01 +09:00
load1, err := strconv.ParseFloat(values[0], 64)
2014-04-18 16:34:47 +09:00
if err != nil {
return LoadAvgStat{}, err
2014-04-18 16:34:47 +09:00
}
2014-04-22 10:12:01 +09:00
load5, err := strconv.ParseFloat(values[1], 64)
2014-04-18 16:34:47 +09:00
if err != nil {
return LoadAvgStat{}, err
2014-04-18 16:34:47 +09:00
}
2014-04-22 10:12:01 +09:00
load15, err := strconv.ParseFloat(values[2], 64)
2014-04-18 16:34:47 +09:00
if err != nil {
return LoadAvgStat{}, err
2014-04-18 16:34:47 +09:00
}
ret := LoadAvgStat{
2014-04-22 10:12:01 +09:00
Load1: float64(load1),
Load5: float64(load5),
Load15: float64(load15),
2014-04-18 16:34:47 +09:00
}
return ret, nil
}