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.
This commit is contained in:
34
agent/stats/reporter_darwin.go
Normal file
34
agent/stats/reporter_darwin.go
Normal file
@@ -0,0 +1,34 @@
|
||||
//go:build darwin
|
||||
|
||||
package stats
|
||||
|
||||
import (
|
||||
"os/exec"
|
||||
"strconv"
|
||||
"strings"
|
||||
)
|
||||
|
||||
func (r *Reporter) memoryStatus() (total, avail uint64) {
|
||||
out, err := exec.Command("sysctl", "-n", "hw.memsize").Output()
|
||||
if err != nil {
|
||||
return 0, 0
|
||||
}
|
||||
total, _ = strconv.ParseUint(strings.TrimSpace(string(out)), 10, 64)
|
||||
out, err = exec.Command("vm_stat").Output()
|
||||
if err != nil {
|
||||
return total, total / 2
|
||||
}
|
||||
// Rough available estimate from vm_stat free pages
|
||||
var pageSize uint64 = 4096
|
||||
var freePages uint64
|
||||
for _, line := range strings.Split(string(out), "\n") {
|
||||
if strings.Contains(line, "Pages free") {
|
||||
parts := strings.Fields(line)
|
||||
if len(parts) >= 3 {
|
||||
freePages, _ = strconv.ParseUint(strings.Trim(parts[2], "."), 10, 64)
|
||||
}
|
||||
}
|
||||
}
|
||||
avail = freePages * pageSize
|
||||
return total, avail
|
||||
}
|
||||
7
agent/stats/reporter_fallback.go
Normal file
7
agent/stats/reporter_fallback.go
Normal file
@@ -0,0 +1,7 @@
|
||||
//go:build !linux && !darwin && !windows
|
||||
|
||||
package stats
|
||||
|
||||
func (r *Reporter) memoryStatus() (total, avail uint64) {
|
||||
return 0, 0
|
||||
}
|
||||
41
agent/stats/reporter_linux.go
Normal file
41
agent/stats/reporter_linux.go
Normal file
@@ -0,0 +1,41 @@
|
||||
//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
|
||||
}
|
||||
50
agent/stats/reporter_unix.go
Normal file
50
agent/stats/reporter_unix.go
Normal file
@@ -0,0 +1,50 @@
|
||||
//go:build !windows
|
||||
|
||||
package stats
|
||||
|
||||
import (
|
||||
"os"
|
||||
"runtime"
|
||||
"sync"
|
||||
)
|
||||
|
||||
type Reporter struct {
|
||||
mu sync.Mutex
|
||||
}
|
||||
|
||||
func NewReporter() *Reporter {
|
||||
return &Reporter{}
|
||||
}
|
||||
|
||||
func (r *Reporter) SystemInfo() (hostname string, cpuCores int, memoryGB int) {
|
||||
hostname, _ = os.Hostname()
|
||||
cpuCores = runtime.NumCPU()
|
||||
total, _ := r.memoryStatus()
|
||||
memoryGB = int(total / (1024 * 1024 * 1024))
|
||||
if memoryGB < 1 {
|
||||
memoryGB = 1
|
||||
}
|
||||
return hostname, cpuCores, memoryGB
|
||||
}
|
||||
|
||||
func (r *Reporter) Usage() (cpuPct float64, memPct float64) {
|
||||
total, avail := r.memoryStatus()
|
||||
if total > 0 {
|
||||
memPct = float64(total-avail) / float64(total) * 100
|
||||
}
|
||||
return 0, memPct
|
||||
}
|
||||
|
||||
func (r *Reporter) FreeMemoryMB() uint64 {
|
||||
_, avail := r.memoryStatus()
|
||||
return avail / (1024 * 1024)
|
||||
}
|
||||
|
||||
func (r *Reporter) TotalMemoryMB() uint64 {
|
||||
total, _ := r.memoryStatus()
|
||||
return total / (1024 * 1024)
|
||||
}
|
||||
|
||||
func (r *Reporter) SystemCPUPercent() float64 {
|
||||
return 0
|
||||
}
|
||||
@@ -1,3 +1,5 @@
|
||||
//go:build windows
|
||||
|
||||
package stats
|
||||
|
||||
import (
|
||||
@@ -54,7 +56,6 @@ func (r *Reporter) Usage() (cpuPct float64, memPct float64) {
|
||||
if total > 0 {
|
||||
memPct = float64(total-avail) / float64(total) * 100
|
||||
}
|
||||
// CPU usage is reported by the agent client from mining load; keep a sane default here.
|
||||
cpuPct = 0
|
||||
return cpuPct, memPct
|
||||
}
|
||||
Reference in New Issue
Block a user