memory_supported.go 458 B

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