crunchstat

package
v0.0.0-...-288f078 Latest Latest
Warning

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

Go to latest
Published: Apr 26, 2024 License: AGPL-3.0, Apache-2.0, CC-BY-SA-3.0 Imports: 20 Imported by: 0

Documentation

Overview

Package crunchstat reports resource usage (CPU, memory, disk, network) for a cgroup.

Index

Constants

This section is empty.

Variables

View Source
var Command = command{}

Functions

This section is empty.

Types

type Reporter

type Reporter struct {
	// Func that returns the pid of a process inside the desired
	// cgroup. Reporter will call Pid periodically until it
	// returns a positive number, then start reporting stats for
	// the cgroup that process belongs to.
	//
	// Pid is used when cgroups v2 is available. For cgroups v1,
	// see below.
	Pid func() int

	// Interval between samples. Must be positive.
	PollPeriod time.Duration

	// Temporary directory, will be monitored for available, used
	// & total space.
	TempDir string

	// Where to write statistics. Must not be nil.
	Logger logPrinter

	// When stats cross thresholds configured in the fields below,
	// they are reported to this logger.
	ThresholdLogger logPrinter

	// MemThresholds maps memory stat names to slices of thresholds.
	// When the corresponding stat exceeds a threshold, that will be logged.
	MemThresholds map[string][]Threshold

	// Filesystem to read /proc entries and cgroup stats from.
	// Non-nil for testing, nil for real root filesystem.
	FS fs.FS

	// Enable debug messages.
	Debug bool
	// contains filtered or unexported fields
}

A Reporter gathers statistics for a cgroup and writes them to a log.Logger.

func (*Reporter) LogMaxima

func (r *Reporter) LogMaxima(logger logPrinter, memLimits map[string]int64)

func (*Reporter) LogProcessMemMax

func (r *Reporter) LogProcessMemMax(logger logPrinter)

func (*Reporter) ReportPID

func (r *Reporter) ReportPID(name string, pid int)

ReportPID starts reporting stats for a specified process.

func (*Reporter) Start

func (r *Reporter) Start()

Start starts monitoring in a new goroutine, and returns immediately.

The monitoring goroutine waits for a non-empty CIDFile to appear (unless CID is non-empty). Then it waits for the accounting files to appear for the monitored container. Then it collects and reports statistics until Stop is called.

Callers should not call Start more than once.

Callers should not modify public data fields after calling Start.

func (*Reporter) Stop

func (r *Reporter) Stop()

Stop reporting. Do not call more than once, or before calling Start.

Nothing will be logged after Stop returns unless you call a Log* method.

type Threshold

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

func NewThresholdFromPercentage

func NewThresholdFromPercentage(total int64, percentage int64) Threshold

func NewThresholdsFromPercentages

func NewThresholdsFromPercentages(total int64, percentages []int64) (thresholds []Threshold)

Jump to

Keyboard shortcuts

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