cpu

package
v0.11.1 Latest Latest
Warning

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

Go to latest
Published: Aug 12, 2024 License: Apache-2.0 Imports: 10 Imported by: 6

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type CPU

type CPU struct {
	User    opt.Uint `struct:"user,omitempty"`
	Sys     opt.Uint `struct:"system,omitempty"`
	Idle    opt.Uint `struct:"idle,omitempty"`
	Nice    opt.Uint `struct:"nice,omitempty"`    // Linux, Darwin, BSD
	Irq     opt.Uint `struct:"irq,omitempty"`     // Linux and openbsd
	Wait    opt.Uint `struct:"iowait,omitempty"`  // Linux and AIX
	SoftIrq opt.Uint `struct:"softirq,omitempty"` // Linux only
	Stolen  opt.Uint `struct:"steal,omitempty"`   // Linux only
}

CPU manages the CPU metrics from /proc/stat If a given metric isn't available on a given platform, The value will be null. All methods that use these fields should assume that any value can be null. The values are in "ticks", which translates to milliseconds of CPU time

func (CPU) Total

func (cpu CPU) Total() uint64

Total returns the total CPU time in ticks as scraped by the API

type CPUInfo added in v0.4.1

type CPUInfo struct {
	ModelName   string
	ModelNumber string
	Mhz         float64
	PhysicalID  int
	CoreID      int
}

CPUInfo manages the CPU information from /proc/cpuinfo If a given value isn't available on a given platformn the value will be the type's zero-value

type CPUMetrics

type CPUMetrics struct {

	// CPUInfo carries some data from /proc/cpuinfo
	CPUInfo []CPUInfo
	// contains filtered or unexported fields
}

CPUMetrics carries global and per-core CPU metrics

func Get

func Get(procfs resolve.Resolver) (CPUMetrics, error)

Get returns a metrics object for CPU data

type MetricOpts

type MetricOpts struct {
	Ticks                 bool
	Percentages           bool
	NormalizedPercentages bool
}

MetricOpts defines the fields that are passed along to the formatted output

type Metrics

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

Metrics stores the current and the last sample collected by a Beat.

func (*Metrics) CPUCount

func (metric *Metrics) CPUCount() int

CPUCount returns the count of CPUs. When available, use this instead of runtime.NumCPU()

func (Metrics) Format

func (metric Metrics) Format(opts MetricOpts) (mapstr.M, error)

Format returns the final MapStr data object for the metrics.

type Monitor

type Monitor struct {
	Hostfs resolve.Resolver
	// contains filtered or unexported fields
}

Monitor is used to monitor the overall CPU usage of the system over time.

func New

func New(hostfs resolve.Resolver) *Monitor

New returns a new CPU metrics monitor Hostfs is only relevant on linux and freebsd.

func (*Monitor) Fetch

func (m *Monitor) Fetch() (Metrics, error)

Fetch collects a new sample of the CPU usage metrics. This will overwrite the currently stored samples.

func (*Monitor) FetchCores

func (m *Monitor) FetchCores() ([]Metrics, error)

FetchCores collects a new sample of CPU usage metrics per-core This will overwrite the currently stored samples.

Jump to

Keyboard shortcuts

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