Files
online-backend/pkg/sysstats/disk_unix.go
GuwandykA e5f01d0e94
Some checks failed
CI/CD / Vet, test, build (push) Has been cancelled
CI/CD / Docker image (push) Has been cancelled
CI/CD / Deploy binary to server (push) Has been cancelled
add docker
2026-10-23 00:39:04 +05:00

25 lines
528 B
Go

//go:build unix
package sysstats
import "syscall"
func diskUsage(path string) (Disk, error) {
var st syscall.Statfs_t
if err := syscall.Statfs(path, &st); err != nil {
return Disk{}, err
}
bsize := uint64(st.Bsize)
total := uint64(st.Blocks) * bsize
free := uint64(st.Bavail) * bsize // space available to non-root users
used := total - uint64(st.Bfree)*bsize
return Disk{
Path: path,
TotalBytes: total,
UsedBytes: used,
FreeBytes: free,
UsagePercent: percent(used, used+free),
}, nil
}