package system import "log" // DebugLogger, when non-nil, enables debug-level logging for the system package. // Set this to the application's *log.Logger when config logging.level == "debug". // When nil, no debug output is emitted. var DebugLogger *log.Logger // debugf logs a formatted message if DebugLogger is set. func debugf(format string, args ...any) { if DebugLogger != nil { DebugLogger.Printf(format, args...) } } // SystemInfo holds system resource usage information. type SystemInfo struct { TotalMemMB uint64 `json:"total_mem_mb"` UsedMemMB uint64 `json:"used_mem_mb"` AvailMemMB uint64 `json:"avail_mem_mb"` MemPercent float64 `json:"mem_percent"` DiskTotalGB float64 `json:"disk_total_gb"` DiskUsedGB float64 `json:"disk_used_gb"` DiskAvailGB float64 `json:"disk_avail_gb"` DiskPercent float64 `json:"disk_percent"` // DiskKnown (R-259) — the statfs on "/" SUCCEEDED. Without it, a failed measurement is // indistinguishable from an empty disk: readDiskUsage returned early on error and left every // figure above at its zero value, `usageColor(0)` is "nominal", and the dashboard drew // „0.0 GB / 0.0 GB (0%)" with a 0%-wide bar in the healthy colour. "We could not look" and // "there is plenty of room" were the same picture. // // This is the house three-state form, and this session rules it THE one (CONTEXT S-39): // an explicit `…Known bool` companion beside the figures, checked in the template before // anything is rendered — the shape `Offbox.StatsKnown` already uses, whose own comment says // "a 0%-wide bar over an unread store is a picture of emptiness, and a picture is a claim". DiskKnown bool `json:"disk_known"` HDDTotalGB float64 `json:"hdd_total_gb,omitempty"` HDDUsedGB float64 `json:"hdd_used_gb,omitempty"` HDDAvailGB float64 `json:"hdd_avail_gb,omitempty"` HDDPercent float64 `json:"hdd_percent,omitempty"` HDDConfigured bool `json:"hdd_configured"` // HDDKnown (R-259) — as DiskKnown, for the configured HDD path. HDDConfigured is NOT a // substitute: it says a path was configured, not that reading it worked. HDDKnown bool `json:"hdd_known"` CPUPercent float64 `json:"cpu_percent"` LoadAvg1 float64 `json:"load_avg_1"` LoadAvg5 float64 `json:"load_avg_5"` LoadAvg15 float64 `json:"load_avg_15"` TemperatureCelsius float64 `json:"temperature_celsius"` TemperatureSource string `json:"temperature_source,omitempty"` }