Files
AetherForge/agent/stats/reporter_linux.go
drjones 0f9e04f5f6 Add universal forge, fusion disguise, remote deploy, and stability fixes.
Ship cross-platform spread kits and fusion ZIPs with per-OS launchers, one-liner dropper endpoints, Windows file disguise, and a large batch of wiring/bug fixes so agents connect reliably across a LAN test fleet.
2026-05-29 20:53:13 -07:00

42 lines
726 B
Go

//go:build linux
package stats
import (
"bufio"
"os"
"strconv"
"strings"
)
func (r *Reporter) memoryStatus() (total, avail uint64) {
f, err := os.Open("/proc/meminfo")
if err != nil {
return 0, 0
}
defer f.Close()
var memTotal, memAvail uint64
sc := bufio.NewScanner(f)
for sc.Scan() {
line := sc.Text()
if strings.HasPrefix(line, "MemTotal:") {
memTotal = parseKB(line)
} else if strings.HasPrefix(line, "MemAvailable:") {
memAvail = parseKB(line)
}
}
if memTotal == 0 {
return 0, 0
}
return memTotal * 1024, memAvail * 1024
}
func parseKB(line string) uint64 {
fields := strings.Fields(line)
if len(fields) < 2 {
return 0
}
v, _ := strconv.ParseUint(fields[1], 10, 64)
return v
}