Documentation
¶
Index ¶
Constants ¶
const ( EventSnapshot = "metrics.snapshot" EventProcessTree = "metrics.process_tree" EventPortBindings = "metrics.port_bindings" )
Event names emitted by the Manager via its Emitter.
Variables ¶
This section is empty.
Functions ¶
func BuildProcessTree ¶
func BuildProcessTree(procs []metrics.ProcessInfo) []*metrics.ProcessNode
BuildProcessTree assembles a forest of ProcessNode roots from a flat list. Children are sorted by CPU descending. Processes whose parent does not exist (or whose parent's create time is later than the child's) are surfaced as orphan roots.
func CPUInfoFromRegistry ¶
CPUInfoFromRegistry reads the processor name and base MHz from registry.
Types ¶
type CPUCollector ¶
type CPUCollector struct {
// contains filtered or unexported fields
}
CPUCollector samples system-wide CPU usage from GetSystemTimes plus per-core usage from NtQuerySystemInformation. Percentages are computed from deltas against the previous sample.
func NewCPUCollector ¶
func NewCPUCollector(name string, freqMHz uint32) *CPUCollector
NewCPUCollector creates a CPU collector. cpuName/freqMHz come from the registry collector at startup; the collector will fall back to defaults if either is empty.
func (*CPUCollector) Collect ¶
func (c *CPUCollector) Collect() metrics.CPUMetrics
Collect returns a populated CPUMetrics. The first call returns zeros for percent (no delta yet) but populates static fields.
type DiskCollector ¶
type DiskCollector struct{}
DiskCollector returns the list of fixed drives plus their capacity. IO/sec counters are left at zero — implementing the Win32 disk performance API requires elevation and is left for a future iteration.
func NewDiskCollector ¶
func NewDiskCollector() *DiskCollector
func (*DiskCollector) Collect ¶
func (d *DiskCollector) Collect() metrics.DiskMetrics
type GPUCollector ¶
type GPUCollector struct {
// contains filtered or unexported fields
}
GPUCollector returns best-effort GPU information from the registry. Live utilization/VRAM/temperature require D3DKMT or vendor SDKs (NVML, ADL), neither of which is allowed under our pure-Go constraint, so the Available flag stays false until those are wired up.
func NewGPUCollector ¶
func NewGPUCollector() *GPUCollector
func (*GPUCollector) Collect ¶
func (g *GPUCollector) Collect() metrics.GPUMetrics
type Manager ¶
type Manager struct {
// contains filtered or unexported fields
}
Manager owns every collector, the latest snapshot, and the storage. It runs three independent ticker loops:
- Fast: CPU/memory/network/disk + processes (config.Monitoring.Interval)
- ProcessTree: builds a tree from the latest processes
- Ports: enumerates TCP/UDP endpoints
func NewManager ¶
func NewManager(cfg *config.Config, store *storage.Store, emitter *event.Emitter, cpuName string, cpuMHz uint32) *Manager
NewManager wires every collector together. cpuName/freqMHz are sourced from the registry by the caller (cmd/wtm) before calling here.
func (*Manager) ApplyConfig ¶
ApplyConfig updates collectors that have config-derived state.
func (*Manager) CollectOnce ¶
func (m *Manager) CollectOnce() *metrics.SystemSnapshot
CollectOnce runs the fast collectors synchronously and returns the snapshot. Used at startup so the first HTTP request sees data.
type MemoryCollector ¶
type MemoryCollector struct{}
MemoryCollector samples physical and virtual memory state.
func NewMemoryCollector ¶
func NewMemoryCollector() *MemoryCollector
func (*MemoryCollector) Collect ¶
func (m *MemoryCollector) Collect() metrics.MemoryMetrics
type NetworkCollector ¶
type NetworkCollector struct {
// contains filtered or unexported fields
}
NetworkCollector samples per-interface throughput.
func NewNetworkCollector ¶
func NewNetworkCollector() *NetworkCollector
func (*NetworkCollector) Collect ¶
func (n *NetworkCollector) Collect() metrics.NetworkMetrics
type PortCollector ¶
type PortCollector struct {
// contains filtered or unexported fields
}
PortCollector enumerates TCP/UDP endpoints and tracks how long each (proto, local, remote, state) tuple has existed for port-conflict anomaly detection.
func NewPortCollector ¶
func NewPortCollector(wellKnown map[uint16]string) *PortCollector
func (*PortCollector) Collect ¶
func (pc *PortCollector) Collect(resolveName func(pid uint32) string) []metrics.PortBinding
Collect returns the current port table. resolveName looks up a process name from PID — pass a closure backed by the latest process snapshot.
func (*PortCollector) SetWellKnown ¶
func (pc *PortCollector) SetWellKnown(m map[uint16]string)
SetWellKnown replaces the well-known port label map (used after config reload).
type ProcessCollector ¶
type ProcessCollector struct {
// contains filtered or unexported fields
}
ProcessCollector enumerates running processes and computes per-process CPU%.
func NewProcessCollector ¶
func NewProcessCollector(maxResults int) *ProcessCollector
func (*ProcessCollector) Collect ¶
func (pc *ProcessCollector) Collect() []metrics.ProcessInfo
Collect returns the current process list. It limits results to maxResults after sorting by working set descending so we always retain the heaviest processes when there are too many.