Download internal/protocol/telemetry_linux.go from st3v3x/FALCON: direct link, hf CLI and curl.
- Browser
- Download file 633 Bytes
-
https://huggingface.co/spaces/st3v3x/FALCON/resolve/main/internal/protocol/telemetry_linux.go
- Command line
-
hf download hf://spaces/st3v3x/FALCON/internal/protocol/telemetry_linux.go
-
curl -L -o telemetry_linux.go https://huggingface.co/spaces/st3v3x/FALCON/resolve/main/internal/protocol/telemetry_linux.go
633 Bytes
| //go:build linux | |
| package protocol | |
| import "syscall" | |
| func collectDiskUsage() (usedMB, totalMB int64, percent float64) { | |
| var stat syscall.Statfs_t | |
| if err := syscall.Statfs("/", &stat); err != nil { | |
| if err := syscall.Statfs(".", &stat); err != nil { | |
| return 0, 0, 0 | |
| } | |
| } | |
| totalBytes := stat.Blocks * uint64(stat.Bsize) | |
| freeBytes := stat.Bavail * uint64(stat.Bsize) | |
| if totalBytes == 0 { | |
| return 0, 0, 0 | |
| } | |
| usedBytes := totalBytes - freeBytes | |
| totalMB = int64(totalBytes / (1024 * 1024)) | |
| usedMB = int64(usedBytes / (1024 * 1024)) | |
| percent = float64(usedBytes) * 100 / float64(totalBytes) | |
| return usedMB, totalMB, percent | |
| } | |