cpu

package
v1.2.2 Latest Latest
Warning

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

Go to latest
Published: Nov 2, 2022 License: BSD-3-Clause Imports: 10 Imported by: 18

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Counts

func Counts(logical bool) (int, error)

func Percent

func Percent(interval time.Duration, percpu bool) ([]float64, error)

Percent calculates the percentage of cpu used either per CPU or combined. If an interval of 0 is given it will compare the current cpu times against the last call.

Types

type InfoStat

type InfoStat struct {
	CPU        int32    `json:"cpu"`
	VendorID   string   `json:"vendorId"`
	Family     string   `json:"family"`
	Model      string   `json:"model"`
	Stepping   int32    `json:"stepping"`
	PhysicalID string   `json:"physicalId"`
	CoreID     string   `json:"coreId"`
	Cores      int32    `json:"cores"`
	ModelName  string   `json:"modelName"`
	Mhz        float64  `json:"mhz"`
	CacheSize  int32    `json:"cacheSize"`
	Flags      []string `json:"flags"`
}

func Info

func Info() ([]InfoStat, error)

CPUInfo on linux will return 1 item per physical thread.

CPUs have three levels of counting: sockets, cores, threads. Cores with HyperThreading count as having 2 threads per core. Sockets often come with many physical CPU cores. For example a single socket board with two cores each with HT will return 4 CPUInfoStat structs on Linux and the "Cores" field set to 1.

func (InfoStat) String

func (c InfoStat) String() string

type TimesStat

type TimesStat struct {
	CPU       string  `json:"cpu"`
	User      float64 `json:"user"`
	System    float64 `json:"system"`
	Idle      float64 `json:"idle"`
	Nice      float64 `json:"nice"`
	Iowait    float64 `json:"iowait"`
	Irq       float64 `json:"irq"`
	Softirq   float64 `json:"softirq"`
	Steal     float64 `json:"steal"`
	Guest     float64 `json:"guest"`
	GuestNice float64 `json:"guestNice"`
	Stolen    float64 `json:"stolen"`
	Timestamp int64   `json:"timestamp"`
}

func Times

func Times(percpu bool) ([]TimesStat, error)

func (TimesStat) String

func (c TimesStat) String() string

func (TimesStat) Total

func (c TimesStat) Total() float64

Total returns the total number of seconds in a CPUTimesStat

Jump to

Keyboard shortcuts

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