cpux

package
v0.0.0-...-df36a95 Latest Latest
Warning

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

Go to latest
Published: Apr 10, 2019 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Overview

Package cpux provides information about a system's cpus, where X is the integer of each CPU on the system, e.g. cpu0, cpu1, etc. On linux systems this comes from the sysfs filesystem. Not all paths are available on all systems, e.g. /sys/devices/system/cpu/cpuX/cpufreq and its children may not exist on some systems. If the system doesn't have a particular path within this path, the field's value will be the type's zero value.

This package does not currently have a ticker implementation.

Index

Constants

View Source
const (
	CPUFreq  = "cpufreq"
	Offline  = "offline"
	Online   = "online"
	Possible = "possible"
	Present  = "present"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type CPU

type CPU struct {
	PhysicalPackageID int32             `json:"physical_package_id"`
	CoreID            int32             `json:"core_id"`
	MHzMin            float32           `json:"mhz_min"`
	MHzMax            float32           `json:"mhz_max"`
	Cache             map[string]string `json:"cache:`
	// a sorted list of caches so that the cache info can be pulled out in order.
	CacheIDs []string `json:"cache_id"`
}

type CPUs

type CPUs struct {
	Sockets  int32  `json:"sockets"`
	Possible string `json:"possible"`
	Online   string `json:"online"`
	Offline  string `json:"offline"`
	Present  string `json:"present"`
	CPU      []CPU  `json:"cpu"`
}

func (*CPUs) GetCPU

func (c *CPUs) GetCPU(pID, coreID int32) (cpu CPU, found bool)

GetCPU returns the cpu information for the provided physical_package_id (pID) and core_id (coreID). A false will be returned if an entry matching the physical_package_id and core_id is not found.

type Profiler

type Profiler struct {
	// this is an exported fied for testing purposes. It should not be set in
	// non-test usage
	NumCPU int
	// contains filtered or unexported fields
}

Profiler is used to process the system's cpuX information.

func NewProfiler

func NewProfiler() (prof *Profiler)

Returns an initialized Profiler; ready to use.

func (*Profiler) Get

func (prof *Profiler) Get() (*CPUs, error)

Get the cpuX info for each cpu. Currently only min and max frequency are implemented.

func (*Profiler) Offline

func (prof *Profiler) Offline() (string, error)

Offline: CPUs that are not online because they have been HOTPLUGGED off (see cpu-hotplug.txt) or exceed the limit of CPUs allowed by the kernel configuration (kernel_max above). [~cpu_online_mask + cpus >= NR_CPUS]. from: Documentation/cputopology.txt

This file may not exist or may only contain a new line char, '\n', neither of these conditions are error states and will result in an empty string.

func (*Profiler) Online

func (prof *Profiler) Online() (string, error)

Online: CPUs that are online and being scheduled [cpu_online_mask] from: Documentation/cputopology.txt

func (*Profiler) Possible

func (prof *Profiler) Possible() (string, error)

Possible: CPUs that have been allocated resources and can be brought online if they are present. [cpu_possible_mask] from: Documentation/cputopology.txt

func (*Profiler) Present

func (prof *Profiler) Present() (string, error)

Present: CPUs that have been identified as being present in the system. [cpu_present_mask] from: Documentation/cputopology.txt

func (*Profiler) Reset

func (prof *Profiler) Reset() error

Reset resources: this does nothing for this implemenation.

func (*Profiler) SysFSSystemPath

func (prof *Profiler) SysFSSystemPath(s string)

SysFSSystemPath enables overriding the default value. This is for testing and should be used outside of tests.

Directories

Path Synopsis
Package cpux provides information about a system's cpus, where X is the integer of each CPU on the system, e.g.
Package cpux provides information about a system's cpus, where X is the integer of each CPU on the system, e.g.
Package cpux provides information about a system's cpus, where X is the integer of each CPU on the system, e.g.
Package cpux provides information about a system's cpus, where X is the integer of each CPU on the system, e.g.

Jump to

Keyboard shortcuts

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