示例#1
0
文件: avg.go 项目: huayueh/sigar
func Avg() C.sigar_loadavg_t {

	var sigar *C.sigar_t = GetSigarHandle()

	var avg C.sigar_loadavg_t

	C.sigar_loadavg_get(sigar, &avg)

	return avg

}
示例#2
0
文件: uptime.go 项目: huayueh/sigar
func _loadAvg(sigar *C.sigar_t) (result []float64, err error) {
	var c_loadAvg C.sigar_loadavg_t

	if status := int(C.sigar_loadavg_get(sigar, &c_loadAvg)); status != SIGAR_OK {
		return nil, fmt.Errorf("Failed to rertieve load avg with error: %v", status)
	}

	loadAvg := (([3]C.double)(c_loadAvg.loadavg)) //[:length]

	return []float64{float64(loadAvg[0]), float64(loadAvg[1]), float64(loadAvg[2])}, nil

}