package cpu

import "github.com/shirou/gopsutil/cpu"

Index

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. Returns one value per cpu, or a single value if percpu is set to false.

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

func Info() ([]InfoStat, error)

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"`
}

TimesStat contains the amounts of time the CPU has spent performing different kinds of work. Time units are in USER_HZ or Jiffies (typically hundredths of a second). It is based on linux /proc/stat file.

func Times

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

Times returns times stat per cpu and combined for all CPUs

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

type Win32_PerfFormattedData_Counters_ProcessorInformation

type Win32_PerfFormattedData_Counters_ProcessorInformation struct {
	Name                  string
	PercentDPCTime        uint64
	PercentIdleTime       uint64
	PercentUserTime       uint64
	PercentProcessorTime  uint64
	PercentInterruptTime  uint64
	PercentPriorityTime   uint64
	PercentPrivilegedTime uint64
	InterruptsPerSec      uint32
	ProcessorFrequency    uint32
	DPCRate               uint32
}

Win32_PerfFormattedData_Counters_ProcessorInformation stores instance value of the perf counters

func PerfInfo

PerfInfo returns the performance counter's instance value for ProcessorInformation. Name property is the key by which overall, per cpu and per core metric is known.

type Win32_PerfFormattedData_PerfOS_System

type Win32_PerfFormattedData_PerfOS_System struct {
	Processes            uint32
	ProcessorQueueLength uint32
}

Win32_PerfFormattedData_PerfOS_System struct to have count of processes and processor queue length

func ProcInfo

ProcInfo returns processes count and processor queue length in the system. There is a single queue for processor even on multiprocessors systems.

type Win32_Processor

type Win32_Processor struct {
	LoadPercentage            *uint16
	Family                    uint16
	Manufacturer              string
	Name                      string
	NumberOfLogicalProcessors uint32
	ProcessorID               *string
	Stepping                  *string
	MaxClockSpeed             uint32
}

Source Files

cpu.go cpu_windows.go

Version
v2.17.12+incompatible
Published
Dec 20, 2017
Platform
windows/amd64
Imports
12 packages
Last checked
5 hours ago

Tools for package owners.