cpumon

package
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Mar 8, 2026 License: Apache-2.0 Imports: 3 Imported by: 0

Documentation

Overview

Package cpumon provides CPU utilization monitoring with platform-specific implementations.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type CPUSample

type CPUSample struct {
	Utilization float64
	Timestamp   time.Time
}

CPUSample is a point-in-time CPU utilization measurement.

type Monitor

type Monitor interface {
	Sample() (CPUSample, error)
}

Monitor samples CPU utilization.

type ProcStat

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

ProcStat reads CPU utilization from /proc/stat.

func NewProcStat

func NewProcStat() (*ProcStat, error)

NewProcStat creates a /proc/stat-based CPU monitor.

func (*ProcStat) Close

func (p *ProcStat) Close() error

Close releases the file handle.

func (*ProcStat) Sample

func (p *ProcStat) Sample() (CPUSample, error)

Sample reads /proc/stat and computes CPU utilization since the last call.

type Synthetic

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

Synthetic is a deterministic CPU monitor for testing.

func NewSynthetic

func NewSynthetic(initial float64) *Synthetic

NewSynthetic creates a synthetic monitor with initial utilization.

func (*Synthetic) Sample

func (s *Synthetic) Sample() (CPUSample, error)

Sample returns the current synthetic utilization.

func (*Synthetic) Set

func (s *Synthetic) Set(util float64)

Set updates the synthetic utilization value.

Jump to

Keyboard shortcuts

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