cpu

package
v0.0.0-...-14435e2 Latest Latest
Warning

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

Go to latest
Published: May 5, 2016 License: BSD-3-Clause Imports: 11 Imported by: 2

Documentation

Index

Constants

This section is empty.

Variables

View Source
var CPUCount = getNumCPU()

Functions

func CPUCounts

func CPUCounts(logical bool) (int, error)

func CPUPercent

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

Types

type CPUInfoStat

type CPUInfoStat struct {
	CPU        int32    `json:"cpu"`
	VendorID   string   `json:"vendor_id"`
	Family     string   `json:"family"`
	Model      string   `json:"model"`
	Stepping   int32    `json:"stepping"`
	PhysicalID string   `json:"physical_id"`
	CoreID     string   `json:"core_id"`
	Cores      int32    `json:"cores"`
	ModelName  string   `json:"model_name"`
	Mhz        float64  `json:"mhz"`
	CacheSize  int32    `json:"cache_size"`
	Flags      []string `json:"flags"`
}

func CPUInfo

func CPUInfo() ([]CPUInfoStat, 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 (CPUInfoStat) String

func (c CPUInfoStat) String() string

type CPUTimesStat

type CPUTimesStat struct {
	CPU       string `json:"cpu"`
	User      uint64 `json:"user"`
	System    uint64 `json:"system"`
	Idle      uint64 `json:"idle"`
	Nice      uint64 `json:"nice"`
	Iowait    uint64 `json:"iowait"`
	Irq       uint64 `json:"irq"`
	Softirq   uint64 `json:"softirq"`
	Steal     uint64 `json:"steal"`
	Guest     uint64 `json:"guest"`
	GuestNice uint64 `json:"guest_nice"`
	Stolen    uint64 `json:"stolen"`
}

Documentation linux: https://www.kernel.org/doc/Documentation/filesystems/proc.txt 1.8

func CPUTimes

func CPUTimes(percpu bool) ([]CPUTimesStat, error)

func (CPUTimesStat) String

func (c CPUTimesStat) String() string

Jump to

Keyboard shortcuts

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