Files
worker/internal/webapp/metrics_linux.go
Gleb Tv 2c7a0236da feat: publish standalone worker
Separate worker packaging and service lifecycle from the control plane.
2026-07-13 17:55:14 +03:00

30 строки
652 B
Go

//go:build linux
package webapp
import (
"syscall"
)
// statDisk fills Total/Free/Used for a DiskSample via statfs(2).
// Linux-only because syscall.Statfs_t is platform-specific. Tests
// that exercise the metric paths stub statDisk at the function
// boundary so the build is hermetic.
func statDisk(mount string, d *DiskSample) error {
var st syscall.Statfs_t
if err := syscall.Statfs(mount, &st); err != nil {
return err
}
bsize := uint64(st.Frsize)
total := st.Blocks * bsize
free := st.Bavail * bsize
used := total - free
d.Total = total
d.Free = free
d.Used = used
if total > 0 {
d.UsedPct = pct(used, total)
}
return nil
}