diff --git a/backend/internal/monitor/disk_linux.go b/backend/internal/monitor/disk_linux.go new file mode 100644 index 0000000..6f78660 --- /dev/null +++ b/backend/internal/monitor/disk_linux.go @@ -0,0 +1,28 @@ +//go:build linux + +package monitor + +import ( + "os" + "syscall" +) + +func getDiskSpaceGB() (float64, float64) { + wd, err := os.Getwd() + if err != nil { + return 0, 0 + } + + var stat syscall.Statfs_t + if err := syscall.Statfs(wd, &stat); err != nil { + return 0, 0 + } + + const gb = 1024.0 * 1024.0 * 1024.0 + blockSize := uint64(stat.Bsize) + + totalBytes := stat.Blocks * blockSize + freeBytes := stat.Bfree * blockSize + + return float64(totalBytes) / gb, float64(freeBytes) / gb +} diff --git a/backend/internal/monitor/disk_other.go b/backend/internal/monitor/disk_other.go index f541806..e0e4499 100644 --- a/backend/internal/monitor/disk_other.go +++ b/backend/internal/monitor/disk_other.go @@ -1,4 +1,4 @@ -//go:build !windows +//go:build !windows && !linux package monitor