Ejemplo n.º 1
0
// GetMemStats returns capacity and usage information about system memory, see sg_get_mem_stats(3).
func GetMemStats() (*MemStats, error) {
	c := C.sg_get_mem_stats()
	if c == nil {
		return nil, getError()
	}
	return &MemStats{
		int64(c.total),
		int64(c.free),
		int64(c.used),
		int64(c.cache)}, nil
}
Ejemplo n.º 2
0
// MemStats get memory & swap related stats
// Go equivalent to sg_get_mem_stats & sg_get_swap_stats
func (s *Stat) MemStats() *MemStats {
	s.Lock()
	defer s.Unlock()

	mem_stats := C.sg_get_mem_stats(nil)
	swap_stats := C.sg_get_swap_stats(nil)

	m := &MemStats{
		Total:     int(mem_stats.total),
		Free:      int(mem_stats.free),
		Used:      int(mem_stats.used),
		Cache:     int(mem_stats.cache),
		SwapTotal: int(swap_stats.total),
		SwapUsed:  int(swap_stats.used),
		SwapFree:  int(swap_stats.free),
	}
	return m
}