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.
51 lines
923 B
Go
51 lines
923 B
Go
//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
|
|
}
|