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 (*Reporter) ReportPID ¶
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.
Click to show internal directories.
Click to hide internal directories.