Emberwake spread/waterhole UI, campaign DB, spread handler, spread-kit web publisher, and SPREAD_TECHNIQUES doc. Crucible Phase A-C: expanded ops, port-forward matrix, remote dir browser, crucible help/tests. Linux agent hardening: credential vault, persistence audit, firewall/defender deploy, SMB spread status, CPU stats, screenshots/crypt/file-ops split. Docker compose and agent/server images with e2e validation script and docs. Musical dashboard: ambient music player, hover SFX, SoundContext/AmbientMusicContext, steampunk polish. Public builds API, dropper handler updates, SessionGate and fleet UX. README and PROBLEMS.md refresh.
52 lines
916 B
Go
52 lines
916 B
Go
//go:build !windows
|
|
|
|
package stats
|
|
|
|
import (
|
|
"os"
|
|
"runtime"
|
|
"sync"
|
|
)
|
|
|
|
type Reporter struct {
|
|
mu sync.Mutex
|
|
|
|
lastIdle uint64
|
|
lastTotal uint64
|
|
hasSample bool
|
|
}
|
|
|
|
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)
|
|
}
|
|
|