memory_supported.go 475 B

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