mirror of
https://github.com/hanzoai/metrics.git
synced 2026-10-30 20:03:39 +00:00
Extends the disk space monitoring functionality by adding support for retrieving total disk capacity in addition to free space. Related: https://github.com/VictoriaMetrics/VictoriaLogs/issues/513 --------- Co-authored-by: Hanzo Dev <[email protected]>
21 lines
421 B
Go
21 lines
421 B
Go
package fs
|
|
|
|
import (
|
|
"golang.org/x/sys/unix"
|
|
)
|
|
|
|
type statfs_t = unix.Statvfs_t
|
|
|
|
func freeSpace(stat statfs_t) uint64 {
|
|
return uint64(stat.Bavail) * uint64(stat.Bsize)
|
|
}
|
|
|
|
// totalSpace returns the total capacity of the filesystem in bytes.
|
|
func totalSpace(stat statfs_t) uint64 {
|
|
return uint64(stat.Blocks) * uint64(stat.Bsize)
|
|
}
|
|
|
|
func statfs(path string, buf *statfs_t) (err error) {
|
|
return unix.Statvfs(path, buf)
|
|
}
|