hoststat

package
v1.3.6 Latest Latest
Warning

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

Go to latest
Published: Jul 23, 2026 License: AGPL-3.0 Imports: 8 Imported by: 0

Documentation

Overview

Package hoststat reads host-level CPU, memory and disk usage from /proc and the filesystem. It has no dependencies on the rest of the codebase so both the server's resource service and the remote agent collector can use it.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DiskUsage

func DiskUsage(path string) (total uint64, used uint64)

DiskUsage returns total and used bytes of the filesystem holding path. Returns (0, 0) if the filesystem cannot be stat'd.

Types

type Reader

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

Reader samples host CPU and memory at 1s intervals via /proc. It runs its own goroutine, independent of any container collector.

func NewReader

func NewReader() *Reader

NewReader creates a reader and takes an initial CPU sample.

func (*Reader) CPUPercent

func (r *Reader) CPUPercent() float64

CPUPercent returns the latest host CPU usage percentage (0-100).

func (*Reader) MemTotal

func (r *Reader) MemTotal() int64

MemTotal returns host total memory in bytes.

func (*Reader) MemUsed

func (r *Reader) MemUsed() int64

MemUsed returns host memory used in bytes.

func (*Reader) Start

func (r *Reader) Start(ctx context.Context)

Start runs the sampling goroutine. Blocks until ctx is cancelled.

Jump to

Keyboard shortcuts

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