hostmon

package
v0.3.21 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 19, 2026 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Overview

Package hostmon samples host CPU/RAM/disk for the read plane (plan §4). The parsing is pure and unit-tested cross-platform; the actual /proc + statfs reads are Linux-specific (the deploy target), with a no-op stub elsewhere so the binary still builds on a dev machine.

Index

Constants

This section is empty.

Variables

View Source
var ErrUnsupported = errors.New("hostmon: host metrics not supported on this platform")

ErrUnsupported is returned by Sample on non-Linux platforms.

Functions

This section is empty.

Types

type Sample

type Sample struct {
	CPUPercent float64
	Load1      float64
	MemTotal   uint64
	MemUsed    uint64
	DiskTotal  uint64
	DiskUsed   uint64
}

Sample is one host metrics reading.

type Sampler

type Sampler struct {
	// contains filtered or unexported fields
}

Sampler holds the previous CPU counters so it can compute instantaneous CPU% from the delta between successive Sample calls.

func New

func New(diskPath string) *Sampler

New returns a Sampler that measures disk usage at diskPath.

func (*Sampler) Sample

func (s *Sampler) Sample() (Sample, error)

Sample reads current host metrics. CPU% is 0 on the first call (no prior counters to diff against).

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL