cpustats

package
v0.0.0-...-df36a95 Latest Latest
Warning

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

Go to latest
Published: Apr 10, 2019 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Overview

Package cpustats handles the processing of information about kernel activity, /proc/stat. The first CPUStats.CPU element aggregates the values for all other CPU elements. The values are aggregated since system boot.

Index

Constants

This section is empty.

Variables

View Source
var CLK_TCK int32 // the ticks per clock cycle

Functions

func ClkTck

func ClkTck() error

Set CLK_TCK.

func NewTicker

func NewTicker(d time.Duration) (joe.Tocker, error)

NewTicker returns a new Ticker containing a Data channel that delivers the data at intervals and an error channel that delivers any errors encountered. Stop the ticker to signal the ticker to stop running. Stopping the ticker does not close the Data channel; call Close to close both the ticker and the data channel.

Types

type CPU

type CPU struct {
	ID        string `json:"ID"`
	User      int64  `json:"user"`
	Nice      int64  `json:"nice"`
	System    int64  `json:"system"`
	Idle      int64  `json:"idle"`
	IOWait    int64  `json:"io_wait"`
	IRQ       int64  `json:"irq"`
	SoftIRQ   int64  `json:"soft_irq"`
	Steal     int64  `json:"steal"`
	Quest     int64  `json:"quest"`
	QuestNice int64  `json:"quest_nice"`
}

CPU holds the stats for a single CPU entry in the /proc/stat file.

type CPUStats

type CPUStats struct {
	ClkTck    int16 `json:"clk_tck"`
	Timestamp int64 `json:"timestamp"`
	Ctxt      int64 `json:"ctxt"`
	BTime     int64 `json:"btime"`
	Processes int64 `json:"processes"`
	CPU       []CPU `json:"cpu"`
}

CPUStats holds the kernel activity information; /proc/stat. The first CPU element's values are the aggregates of all other CPU elements. The stats are aggregated from sytem boot.

func Get

func Get() (stat *CPUStats, err error)

Get returns the current kernel activity information using the package's global Profiler.

type Profiler

type Profiler struct {
	joe.Procer
	*joe.Buffer
	ClkTck int16
}

Profiler is used to process the /proc/stats file.

func NewProfiler

func NewProfiler() (prof *Profiler, err error)

Returns an initialized Profiler; ready to use.

func (*Profiler) Get

func (prof *Profiler) Get() (stats *CPUStats, err error)

Get returns information about current kernel activity.

func (*Profiler) Reset

func (prof *Profiler) Reset() error

Reset resources: after reset, the profiler is ready to be used again.

type Ticker

type Ticker struct {
	*joe.Ticker
	Data chan *CPUStats
	*Profiler
}

Ticker delivers the system's kernel activity information at intervals.

func (*Ticker) Close

func (t *Ticker) Close()

Close closes the ticker resources.

func (*Ticker) Run

func (t *Ticker) Run()

Run runs the ticker.

Directories

Path Synopsis
Package cpustats handles Flatbuffer based processing of kernel activity, /proc/stat.
Package cpustats handles Flatbuffer based processing of kernel activity, /proc/stat.
Package cpustats handles JSON based processing of kernel activity, /proc/stat.
Package cpustats handles JSON based processing of kernel activity, /proc/stat.

Jump to

Keyboard shortcuts

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