func getLoad() ([]float64, error) { var loadavg [3]C.double samples := C.getloadavg(&loadavg[0], 3) if samples > 0 { return []float64{float64(loadavg[0]), float64(loadavg[1]), float64(loadavg[2])}, nil } else { return nil, errors.New("failed to get load average") } }
func GetMetric(params interface{}, log *logger.Logger) interface{} { var loadavg [3]C.double log.Log("debug", "Calling getloadavg()") C.getloadavg(&loadavg[0], 3) return loadavg }
func getLoad1() (float64, error) { var loadavg [1]C.double samples := C.getloadavg(&loadavg[0], 1) if samples > 0 { return float64(loadavg[0]), nil } else { return 0, errors.New("failed to get load average") } }
// Returns system load averages. func getSystemLoadaverage() ([3]float32, error) { avg := []C.double{0, 0, 0} n := C.getloadavg(&avg[0], C.int(len(avg))) if n == -1 { return [3]float32{0, 0, 0}, errors.New("load average unavailable") } return [3]float32{float32(avg[0]), float32(avg[1]), float32(avg[2])}, nil }
// Collect populates Loadstat by using getloadavg func (s *LoadStat) Collect() { var loadavg [3]C.double //get system load averages C.getloadavg(&loadavg[0], 3) s.OneMinute.Set(float64(loadavg[0])) s.FiveMinute.Set(float64(loadavg[1])) s.FifteenMinute.Set(float64(loadavg[2])) }
func (self *LoadAverage) Get() error { avg := []C.double{0, 0, 0} C.getloadavg(&avg[0], C.int(len(avg))) self.One = float64(avg[0]) self.Five = float64(avg[1]) self.Fifteen = float64(avg[2]) return nil }