feat: publish standalone worker
Separate worker packaging and service lifecycle from the control plane.
Этот коммит содержится в:
29
internal/webapp/metrics_linux.go
Обычный файл
29
internal/webapp/metrics_linux.go
Обычный файл
@@ -0,0 +1,29 @@
|
||||
//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
|
||||
}
|
||||
Ссылка в новой задаче
Block a user