2021-09-01 17:45:42 +08:00
|
|
|
//go:build !windows && !openbsd && !netbsd && !plan9 && !solaris
|
2014-07-25 03:24:01 +08:00
|
|
|
// +build !windows,!openbsd,!netbsd,!plan9,!solaris
|
2014-03-29 03:18:01 +08:00
|
|
|
|
|
|
|
package stats
|
|
|
|
|
|
|
|
import (
|
|
|
|
"syscall"
|
2018-10-16 13:25:28 +08:00
|
|
|
|
|
|
|
"github.com/chrislusf/seaweedfs/weed/pb/volume_server_pb"
|
2014-03-29 03:18:01 +08:00
|
|
|
)
|
|
|
|
|
2018-10-16 13:25:28 +08:00
|
|
|
func fillInDiskStatus(disk *volume_server_pb.DiskStatus) {
|
2014-03-29 03:18:01 +08:00
|
|
|
fs := syscall.Statfs_t{}
|
|
|
|
err := syscall.Statfs(disk.Dir, &fs)
|
|
|
|
if err != nil {
|
|
|
|
return
|
|
|
|
}
|
|
|
|
disk.All = fs.Blocks * uint64(fs.Bsize)
|
|
|
|
disk.Free = fs.Bfree * uint64(fs.Bsize)
|
|
|
|
disk.Used = disk.All - disk.Free
|
2020-02-24 05:25:56 +08:00
|
|
|
disk.PercentFree = float32((float64(disk.Free) / float64(disk.All)) * 100)
|
|
|
|
disk.PercentUsed = float32((float64(disk.Used) / float64(disk.All)) * 100)
|
2014-03-29 03:18:01 +08:00
|
|
|
return
|
|
|
|
}
|