Documentation
¶
Overview ¶
Package hostinfo reads what the machine the cockpit runs on is up to: how busy it is, how much memory is in use, and how full the disk under the projects is. Three percentages, cheap enough to read while a browser is connected, and nothing to configure.
Everything here stays free of cgo, because the released binaries are built that way. On Linux the kernel publishes its busy counters in /proc/stat, so the busy number there is the real share of the cores at work, the delta between two readings. macOS keeps the same counters behind mach calls that would need cgo, so there the busy number stays the load average against the core count: already averaged over a minute, and it may pass 100 percent when more work is queued than the machine can run at once. That is information, not a bug, and the CPU label says which of the two the number is.
Index ¶
Constants ¶
const ( Warn = 80 Crit = 95 )
Warn and Crit are the thresholds a surface colors on: quiet below Warn, yellow from Warn, red from Crit.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Cache ¶
type Cache struct {
// contains filtered or unexported fields
}
Cache reads at most once per interval, so every connected browser shares one reading instead of each heartbeat costing its own.
type Stats ¶
type Stats struct {
HasCPU bool `json:"hasCpu"`
HasMem bool `json:"hasMem"`
HasDisk bool `json:"hasDisk"`
CPUPercent int `json:"cpu"`
MemPercent int `json:"mem"`
DiskPercent int `json:"disk"`
CPULabel string `json:"cpuLabel"`
MemLabel string `json:"memLabel"`
DiskLabel string `json:"diskLabel"`
// Level is "", "warn" or "crit", taken from the worst of the readings.
Level string `json:"level"`
}
Stats is one reading. A metric the platform could not answer keeps its Has flag false and its percentage at -1, so a surface can leave that row out instead of showing a zero that would read as "idle".