crunchstat

package
v0.0.0-...-c92af4d Latest Latest
Warning

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

Go to latest
Published: Jul 1, 2021 License: AGPL-3.0, Apache-2.0, CC-BY-SA-3.0 Imports: 13 Imported by: 0

Documentation

Overview

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

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Reporter

type Reporter struct {
	// CID of the container to monitor. If empty, read the CID
	// from CIDFile (first waiting until a non-empty file appears
	// at CIDFile). If CIDFile is also empty, report host
	// statistics.
	CID string

	// Path to a file we can read CID from.
	CIDFile string

	// Where cgroup accounting files live on this system, e.g.,
	// "/sys/fs/cgroup".
	CgroupRoot string

	// Parent cgroup, e.g., "docker".
	CgroupParent string

	// 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 *log.Logger
	// contains filtered or unexported fields
}

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

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.

Jump to

Keyboard shortcuts

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