fix: The free disk size and percentage are quite different from the output of df -h. (#6550)

* fix: record and delete bucket metrics after inactive

* feat: match available disk size with system cmd `dh -h`

* feat: move temp test to unmaintained/

---------

Co-authored-by: XYZ <XYZ>
This commit is contained in:
zouyixiong
2025-02-18 07:49:11 +08:00
committed by GitHub
parent c2b8942769
commit 7392161894
2 changed files with 62 additions and 1 deletions

View File

@@ -16,7 +16,11 @@ func fillInDiskStatus(disk *volume_server_pb.DiskStatus) {
return
}
disk.All = fs.Blocks * uint64(fs.Bsize)
disk.Free = fs.Bfree * uint64(fs.Bsize)
// https://man7.org/linux/man-pages/man3/statvfs.3.html
// fs.Bfree: Number of free blocks
// fs.Bavail: Number of free blocks for unprivileged users
// disk.Free = fs.Bfree * uint64(fs.Bsize)
disk.Free = fs.Bavail * uint64(fs.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)