Files
metrics/lib/fs/fs_netbsd.go
a6626daf47 lib/fs: Add total disk space retrieval (#9523)
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]>
2025-08-04 09:58:19 +02:00

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)
}