func GetMemInfo() (result *MemInfo, err error) { defer util.Panic2Error(&err) var sigar *C.sigar_t = GetSigarHandle() var mem C.sigar_mem_t var swap C.sigar_swap_t C.sigar_mem_get(sigar, &mem) C.sigar_swap_get(sigar, &swap) return &MemInfo{ Mem: &Mem{ Ram: uint64(mem.ram), Total: uint64(mem.total), Used: uint64(mem.used), Free: uint64(mem.free), ActualUsed: uint64(mem.actual_used), ActualFree: uint64(mem.actual_free), UsedPerecent: float64(mem.used_percent), FreePerecent: float64(mem.free_percent), }, Swap: &Swap{ Total: uint64(swap.total), Used: uint64(swap.used), Free: uint64(swap.free), PageIn: uint64(swap.page_in), PageOut: uint64(swap.page_out), }, }, nil }
func GetTotalMem() (total uint64, err error) { defer util.Panic2Error(&err) var sigar *C.sigar_t = GetSigarHandle() var mem C.sigar_mem_t status := int(C.sigar_mem_get(sigar, &mem)) if status != SIGAR_OK { return 0, fmt.Errorf("Failed to rertieve sys mem info with error: %v", status) } return uint64(mem.total), nil }