You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

24 lines
646 B

3 years ago
  1. //go:build !windows && !openbsd && !netbsd && !plan9 && !solaris
  2. // +build !windows,!openbsd,!netbsd,!plan9,!solaris
  3. package stats
  4. import (
  5. "syscall"
  6. "github.com/chrislusf/seaweedfs/weed/pb/volume_server_pb"
  7. )
  8. func fillInDiskStatus(disk *volume_server_pb.DiskStatus) {
  9. fs := syscall.Statfs_t{}
  10. err := syscall.Statfs(disk.Dir, &fs)
  11. if err != nil {
  12. return
  13. }
  14. disk.All = fs.Blocks * uint64(fs.Bsize)
  15. disk.Free = fs.Bfree * uint64(fs.Bsize)
  16. disk.Used = disk.All - disk.Free
  17. disk.PercentFree = float32((float64(disk.Free) / float64(disk.All)) * 100)
  18. disk.PercentUsed = float32((float64(disk.Used) / float64(disk.All)) * 100)
  19. return
  20. }