Files
metrics/lib/fs/fs_openbsd.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
429 B
Go

package fs
import (
"golang.org/x/sys/unix"
)
type statfs_t = unix.Statfs_t
func freeSpace(stat statfs_t) uint64 {
return uint64(stat.F_bavail) * uint64(stat.F_bsize)
}
// totalSpace returns the total capacity of the filesystem in bytes.
func totalSpace(stat statfs_t) uint64 {
return uint64(stat.F_blocks) * uint64(stat.F_bsize)
}
func statfs(path string, stat *statfs_t) (err error) {
return unix.Statfs(path, stat)
}