cpu

package
v0.0.1-alpha2 Latest Latest
Warning

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

Go to latest
Published: Aug 20, 2024 License: Apache-2.0 Imports: 19 Imported by: 0

Documentation

Overview

Package cpu tracks the combined usage of all CPUs (not per-CPU).

Index

Constants

View Source
const (
	StateNameInfo         = "info"
	StateKeyInfoCPU       = "cpu"
	StateKeyInfoArch      = "arch"
	StateKeyInfoFamily    = "family"
	StateKeyInfoModel     = "model"
	StateKeyInfoModelName = "model_name"

	StateNameCores        = "cores"
	StateKeyCoresPhysical = "physical"
	StateKeyCoresLogical  = "logical"

	StateNameUsage            = "usage"
	StateKeyUsageUsedPercent  = "used_percent"
	StateKeyUsageLoadAvg1Min  = "load_avg_1min"
	StateKeyUsageLoadAvg5Min  = "load_avg_5min"
	StateKeyUsageLoadAvg15Min = "load_avg_15min"
)
View Source
const Name = "cpu"

Variables

This section is empty.

Functions

func Get

func Get(ctx context.Context) (_ any, e error)

func New

Types

type Config

type Config struct {
	Query query_config.Config `json:"query"`
}

func ParseConfig

func ParseConfig(b any, db *sql.DB) (*Config, error)

func (Config) Validate

func (cfg Config) Validate() error

type Cores

type Cores struct {
	Physical int `json:"physical"`
	Logical  int `json:"logical"`
}

func ParseStateKeyCores

func ParseStateKeyCores(m map[string]string) (Cores, error)

type Info

type Info struct {
	Arch      string `json:"arch"`
	CPU       string `json:"cpu"`
	Family    string `json:"family"`
	Model     string `json:"model"`
	ModelName string `json:"model_name"`
}

func ParseStateInfo

func ParseStateInfo(m map[string]string) (Info, error)

type Output

type Output struct {
	Info  Info  `json:"info"`
	Cores Cores `json:"cores"`
	Usage Usage `json:"usage"`
}

func ParseOutputJSON

func ParseOutputJSON(data []byte) (*Output, error)

func ParseStatesToOutput

func ParseStatesToOutput(states ...components.State) (*Output, error)

func (*Output) JSON

func (o *Output) JSON() ([]byte, error)

func (*Output) States

func (o *Output) States() ([]components.State, error)

type Usage

type Usage struct {
	// Used CPU in percentage.
	UsedPercent string `json:"used_percent"`

	// Load average for the last 1-minute, with the scale of 1.00.
	LoadAvg1Min string `json:"load_avg_1min"`
	// Load average for the last 5-minutes, with the scale of 1.00.
	LoadAvg5Min string `json:"load_avg_5min"`
	// Load average for the last 15-minutes, with the scale of 1.00.
	LoadAvg15Min string `json:"load_avg_15min"`
}

func ParseStateUsage

func ParseStateUsage(m map[string]string) (Usage, error)

func (Usage) GetLoadAvg15Min

func (u Usage) GetLoadAvg15Min() (float64, error)

func (Usage) GetLoadAvg1Min

func (u Usage) GetLoadAvg1Min() (float64, error)

func (Usage) GetLoadAvg5Min

func (u Usage) GetLoadAvg5Min() (float64, error)

func (Usage) GetUsedPercent

func (u Usage) GetUsedPercent() (float64, error)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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