disk_supported.go 581 B

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