You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

21 lines
467 B

//go:build linux
package systemmetrics
import (
"errors"
"golang.org/x/sys/unix"
"tera-clone/services/tera-api/internal/domain"
)
func readStorage(path string) (*domain.StorageMetrics, error) {
var stat unix.Statfs_t
if err := unix.Statfs(path, &stat); err != nil {
return nil, err
}
if stat.Bsize <= 0 {
return nil, errors.New("invalid filesystem block size")
}
return storageMetrics(path, stat.Blocks, stat.Bfree, stat.Bavail, uint64(stat.Bsize))
}