Dominic Pearson
7 months ago
committed by
GitHub
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
5 changed files with
47 additions and
8 deletions
-
weed/stats/disk_common.go
-
weed/stats/disk_notsupported.go
-
weed/stats/disk_openbsd.go
-
weed/stats/disk_solaris.go
-
weed/stats/disk_windows.go
|
|
@ -0,0 +1,17 @@ |
|
|
|
package stats |
|
|
|
|
|
|
|
import "github.com/seaweedfs/seaweedfs/weed/pb/volume_server_pb" |
|
|
|
|
|
|
|
func calculateDiskRemaining(disk *volume_server_pb.DiskStatus) { |
|
|
|
disk.Used = disk.All - disk.Free |
|
|
|
|
|
|
|
if disk.All > 0 { |
|
|
|
disk.PercentFree = float32((float64(disk.Free) / float64(disk.All)) * 100) |
|
|
|
disk.PercentUsed = float32((float64(disk.Used) / float64(disk.All)) * 100) |
|
|
|
} else { |
|
|
|
disk.PercentFree = 0 |
|
|
|
disk.PercentUsed = 0 |
|
|
|
} |
|
|
|
|
|
|
|
return |
|
|
|
} |
|
|
@ -1,5 +1,5 @@ |
|
|
|
//go:build netbsd || plan9 || solaris
|
|
|
|
// +build netbsd plan9 solaris
|
|
|
|
//go:build netbsd || plan9
|
|
|
|
// +build netbsd plan9
|
|
|
|
|
|
|
|
package stats |
|
|
|
|
|
|
|
|
|
@ -15,10 +15,10 @@ func fillInDiskStatus(disk *volume_server_pb.DiskStatus) { |
|
|
|
if err != nil { |
|
|
|
return |
|
|
|
} |
|
|
|
|
|
|
|
disk.All = fs.F_blocks * uint64(fs.F_bsize) |
|
|
|
disk.Free = fs.F_bfree * uint64(fs.F_bsize) |
|
|
|
disk.Used = disk.All - disk.Free |
|
|
|
disk.PercentFree = float32((float64(disk.Free) / float64(disk.All)) * 100) |
|
|
|
disk.PercentUsed = float32((float64(disk.Used) / float64(disk.All)) * 100) |
|
|
|
calculateDiskRemaining(disk) |
|
|
|
|
|
|
|
return |
|
|
|
} |
|
|
@ -0,0 +1,24 @@ |
|
|
|
//go:build solaris
|
|
|
|
// +build solaris
|
|
|
|
|
|
|
|
package stats |
|
|
|
|
|
|
|
import ( |
|
|
|
"golang.org/x/sys/unix" |
|
|
|
|
|
|
|
"github.com/seaweedfs/seaweedfs/weed/pb/volume_server_pb" |
|
|
|
) |
|
|
|
|
|
|
|
func fillInDiskStatus(disk *volume_server_pb.DiskStatus) { |
|
|
|
var stat unix.Statvfs_t |
|
|
|
err := unix.Statvfs(disk.Dir, &stat) |
|
|
|
if err != nil { |
|
|
|
return |
|
|
|
} |
|
|
|
|
|
|
|
disk.All = stat.Blocks * uint64(stat.Bsize) |
|
|
|
disk.Free = stat.Bfree * uint64(stat.Bsize) |
|
|
|
calculateDiskRemaining(disk) |
|
|
|
|
|
|
|
return |
|
|
|
} |
|
|
@ -39,9 +39,7 @@ func fillInDiskStatus(disk *volume_server_pb.DiskStatus) { |
|
|
|
|
|
|
|
return |
|
|
|
} |
|
|
|
disk.Used = disk.All - disk.Free |
|
|
|
disk.PercentFree = float32((float64(disk.Free) / float64(disk.All)) * 100) |
|
|
|
disk.PercentUsed = float32((float64(disk.Used) / float64(disk.All)) * 100) |
|
|
|
calculateDiskRemaining(disk) |
|
|
|
|
|
|
|
return |
|
|
|
} |