Documentation
¶
Overview ¶
Package hoststats reads host CPU and memory from procfs, shared by control plane and agent so figures can't drift.
Index ¶
- Variables
- func Available(procPath string) bool
- func CPUPercent(a, b CPUTimes) float64
- func MemFromVals(vals map[string]uint64) (total, avail uint64, err error)
- func ParseMemLine(line string) (key string, kb uint64, ok bool)
- func ReadLoad1(procPath string) (float64, error)
- func ReadMem(procPath string) (total, avail uint64, err error)
- func ReadUptime(procPath string) (uint64, error)
- type CPUTimes
- type Report
- type Sampler
- type Stats
Constants ¶
This section is empty.
Variables ¶
var ErrNoBaseline = errors.New("hoststats: no cpu baseline yet")
ErrNoBaseline is returned by Sampler.Sample until it has a previous CPU reading to measure against.
Functions ¶
func ParseMemLine ¶
ParseMemLine splits one meminfo row into its key and kB value.
func ReadUptime ¶
ReadUptime reads the host's uptime in whole seconds from procPath/uptime.
Types ¶
type CPUTimes ¶
CPUTimes is the aggregate "cpu" row of /proc/stat, in jiffies.
func ParseCPULine ¶
Shared with the remote sampler, which gets the line from a helper container's stdout.
type Report ¶
type Report struct {
CPUPercent float64 `json:"cpu_percent"`
MemTotalBytes uint64 `json:"mem_total_bytes"`
MemUsedBytes uint64 `json:"mem_used_bytes"`
Load1 float64 `json:"load1"`
UptimeSeconds uint64 `json:"uptime_s"`
}
Report carries no identity or timestamp: the control plane takes the node from the token and stamps receipt.
type Sampler ¶
type Sampler struct {
ProcPath string
// contains filtered or unexported fields
}
Sampler averages CPU over the whole interval since the last call, so bursty workloads are measured honestly.