package cpu
import "github.com/shirou/gopsutil/v3/cpu"
Index ¶
- Variables
- func Counts(logical bool) (int, error)
- func CountsWithContext(ctx context.Context, logical bool) (int, error)
- func Percent(interval time.Duration, percpu bool) ([]float64, error)
- func PercentWithContext(ctx context.Context, interval time.Duration, percpu bool) ([]float64, error)
- type InfoStat
- func Info() ([]InfoStat, error)
- func InfoWithContext(ctx context.Context) ([]InfoStat, error)
- func (c InfoStat) String() string
- type TimesStat
Variables ¶
var ClocksPerSec = float64(100)
Functions ¶
func Counts ¶
Counts returns the number of physical or logical cores in the system
func CountsWithContext ¶
func Percent ¶
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. Returns one value per cpu, or a single value if percpu is set to false.
func PercentWithContext ¶
func PercentWithContext(ctx context.Context, interval time.Duration, percpu bool) ([]float64, error)
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"`
Microcode string `json:"microcode"`
}
func Info ¶
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 InfoWithContext ¶
func (InfoStat) 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"`
}
TimesStat contains the amounts of time the CPU has spent performing different kinds of work. Time units are in seconds. It is based on linux /proc/stat file.
func Times ¶
func TimesWithContext ¶
func (TimesStat) String ¶
func (TimesStat) Total ¶
Deprecated: Total returns the total number of seconds in a CPUTimesStat Please do not use this internal function.
Source Files ¶
- Version
- v3.24.5 (latest)
- Published
- May 28, 2024
- Platform
- linux/amd64
- Imports
- 13 packages
- Last checked
- 6 months ago –
Tools for package owners.