コード例 #1
0
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")
	}
}
コード例 #2
0
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
}
コード例 #3
0
ファイル: loadavg.go プロジェクト: kirussel/node_exporter
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")
	}

}
コード例 #4
0
ファイル: osutil_freebsd.go プロジェクト: 0987363/zfswatcher
// 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
}
コード例 #5
0
ファイル: loadstat_darwin.go プロジェクト: njuettner/inspect
// 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]))
}
コード例 #6
0
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
}