Documentation
¶
Overview ¶
Package sysinfo gathers OS-level resource metrics (memory, swap, disk, load) and evaluates them against configurable thresholds to produce alerts at WARNING and DANGER severity levels.
Platform support uses build tags: Linux reads /proc, macOS shells out to sysctl/vm_stat, and other platforms return Supported: false gracefully.
Index ¶
Constants ¶
const ( ResourceMemory = "memory" ResourceSwap = "swap" ResourceDisk = "disk" ResourceLoad = "load" )
Resource name constants for threshold evaluation.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type MemInfo ¶
type MemInfo struct {
TotalBytes uint64
UsedBytes uint64
SwapTotalBytes uint64
SwapUsedBytes uint64
Supported bool
}
MemInfo holds memory and swap usage metrics.
type ResourceAlert ¶
ResourceAlert describes a single threshold breach.
func Evaluate ¶
func Evaluate(snap Snapshot) []ResourceAlert
Evaluate checks a snapshot against resource thresholds and returns any alerts. Unsupported or zero-total resources are silently skipped.
Thresholds:
- Memory: WARNING >= 80%, DANGER >= 90%
- Swap: WARNING >= 50%, DANGER >= 75%
- Disk: WARNING >= 85%, DANGER >= 95%
- Load: WARNING >= 0.8x CPUs, DANGER >= 1.5x CPUs
Parameters:
- snap: System resource snapshot to evaluate
Returns:
- []ResourceAlert: Alerts for any resources exceeding thresholds
type Severity ¶
type Severity int
Severity represents the urgency level of a resource alert.
func MaxSeverity ¶
func MaxSeverity(alerts []ResourceAlert) Severity
MaxSeverity returns the highest severity among the given alerts.
Returns SeverityOK when the slice is empty.
Parameters:
- alerts: Resource alerts to evaluate
Returns:
- Severity: Highest severity found, or SeverityOK if empty
func SeverityFor ¶
func SeverityFor(alerts []ResourceAlert, resource string) Severity
SeverityFor returns the severity level for a given resource name from an alert list. Returns SeverityOK if no alert matches.
Parameters:
- alerts: list of resource alerts to search
- resource: resource name to match (e.g., "memory", "disk")
Returns:
- Severity: the severity level for the resource