sysstat

package
v1.3.0 Latest Latest
Warning

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

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

Documentation

Overview

Package sysstat samples host metrics (CPU, memory, swap, disk, network) from /proc on Linux. On platforms without /proc (e.g. local dev on macOS) the readers fail softly and return zeros — the panel still runs.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ProcMem

func ProcMem() int64

ProcMem returns the panel process's resident set size (RSS) in bytes, read from /proc/self/status. 0 if unavailable.

Types

type Sampler

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

Sampler maintains rolling CPU% and network rates via a background ticker.

func New

func New(diskPath string) *Sampler

New starts a sampler that refreshes CPU/network rates every 2s.

func (*Sampler) Read

func (s *Sampler) Read() Stats

Read returns the current snapshot (cheap; on-demand for mem/disk/uptime).

type Stats

type Stats struct {
	CPUPercent float64 `json:"cpu_percent"`
	MemUsed    int64   `json:"mem_used"`
	MemTotal   int64   `json:"mem_total"`
	SwapUsed   int64   `json:"swap_used"`
	SwapTotal  int64   `json:"swap_total"`
	DiskUsed   int64   `json:"disk_used"`
	DiskTotal  int64   `json:"disk_total"`
	HostUptime int64   `json:"host_uptime"` // seconds
	NetUp      int64   `json:"net_up"`      // bytes/sec
	NetDown    int64   `json:"net_down"`    // bytes/sec
}

Stats is a point-in-time host snapshot. Byte fields are absolute; Net* are per-second rates.

Jump to

Keyboard shortcuts

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