memory_supported.go 381 B

123456789101112131415161718
  1. // +build linux
  2. package stats
  3. import (
  4. "syscall"
  5. )
  6. func (mem *MemStatus) fillInStatus() {
  7. //system memory usage
  8. sysInfo := new(syscall.Sysinfo_t)
  9. err := syscall.Sysinfo(sysInfo)
  10. if err == nil {
  11. mem.All = uint64(sysInfo.Totalram) //* uint64(syscall.Getpagesize())
  12. mem.Free = uint64(sysInfo.Freeram) //* uint64(syscall.Getpagesize())
  13. mem.Used = mem.All - mem.Free
  14. }
  15. }