stat

package
v0.0.0-...-3f331ed Latest Latest
Warning

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

Go to latest
Published: Jul 3, 2021 License: MIT Imports: 2 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CPUUsage

func CPUUsage(cur, prev CPUer) float64

CPUUsage calculates the CPU usage percentage during the period between the two given CPUusagers.

Types

type CPUer

type CPUer interface {
	// The total amount of time units spent in CPU since last boot.
	TotalCPU() int
	// The total amount of time units spent since last boot.
	Total() int
}

CPUer represents the time units spent since last boot and the ones spent in CPU tasks. This two values allows to calculate CPU usage percentages.

type S

type S struct {
	// Time spent in user mode.
	User int
	// Time spent in user mode with low priority.
	Nice int
	// Time spent in system mode.
	System int
	// Time spent in the idle task.
	Idle int
	// Time waiting for I/O to complete.
	IOWait int
	// Time servicing interrupts.
	IRQ int
	// Time servicing soft interrupts.
	SoftIRQ int
	// Stolen time (time spent in other OS when running in a virtualized
	// environment.
	Steal int
	// Time spent running virtual CPU for guest OSs under the control of
	// the kernel.
	Guest int
	// Time spent running a niced guest.
	NiceGuest int
}

S values contain the amount of time spent by the CPU in different states, measured in USER_HZ (1/100 secs in most systems).

This assumes Linux > 2.6.33.

func New

func New() (_ *S, err error)

func (*S) String

func (s *S) String() string

func (*S) Total

func (s *S) Total() int

func (*S) TotalCPU

func (s *S) TotalCPU() int

func (*S) TotalIdle

func (s *S) TotalIdle() int

Jump to

Keyboard shortcuts

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