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.
42 lines
726 B
Go
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
|
|
}
|