sysstat

package
v0.2.2 Latest Latest
Warning

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

Go to latest
Published: Nov 20, 2026 License: Apache-2.0 Imports: 15 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package sysstat reads the machine conch's server runs on: its CPU and each core, memory and where it goes, load, disk, and every process with its CPU and memory — for system.stats, the window beside the resource monitor. It reads only when asked, and keeps an hour of history while somebody keeps asking.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Pick

func Pick(all []proto.SystemProcess, n, most int) []proto.SystemProcess

Pick is what a window lists of every process: the n busiest and the n largest, and every one conch started, at most max, the busiest first.

func Trees

func Trees(all []proto.SystemProcess, roots []int) map[int][]int

Trees is each root's process and everything under it, a process counted under the first root that reaches it: so the panes are given before the server, whose children they are.

Types

type CPUTicks

type CPUTicks struct {
	All   Ticks
	Cores []Ticks
}

CPUTicks is the whole machine's and each core's.

type Proc

type Proc struct {
	PID, PPID int
	Name      string
	User      string
	RSS       uint64 // bytes
	CPU       float64
	Threads   int
	Started   time.Time
}

Proc is one process at one moment. CPU is the processor time it has used so far, in seconds: only the difference between two readings says how busy it is.

type Sampler

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

Sampler answers system.stats. Its zero value is not usable: New.

func New

func New(src Source) *Sampler

New makes a sampler over src.

func (*Sampler) Stats

Stats is the machine now. tag names the processes conch started — it is given every process, and its parents, before any is picked to list.

func (*Sampler) Stop

func (s *Sampler) Stop()

Stop ends the history's upkeep; Stats still answers afterwards.

type Source

type Source struct {
	Host     func() proto.SystemHost
	Ticks    func() (CPUTicks, bool)
	Memory   func(ctx context.Context) (*proto.SystemMemory, bool)
	Load     func() []float64
	Disk     func() *proto.SystemDisk
	Procs    func(ctx context.Context) ([]Proc, error)
	Commands func(ctx context.Context, pids []int) map[int]string
}

Source is where the readings come from: the machine's own (Local), or a test's. A reader left nil is something the machine does not say.

func Local

func Local() Source

Local is this machine's source.

type Ticks

type Ticks struct {
	Busy, Idle uint64
	User, Sys  uint64 // parts of Busy, where the system says
}

Ticks is time a processor spent, in whatever unit its system counts: only differences between two readings mean anything.

Jump to

Keyboard shortcuts

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