apidata

package
v0.5.4 Latest Latest
Warning

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

Go to latest
Published: May 29, 2024 License: MPL-2.0 Imports: 8 Imported by: 0

Documentation

Overview

Package apidata implements the types and the data sources for the data sourced from various Talos APIs.

Package apidata implements types to handle monitoring data, calculate values from it, etc.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Data

type Data struct {
	// Data per each node.
	Nodes map[string]*Node

	Timestamp time.Time
	Interval  time.Duration
}

Data represents the monitoring data retrieved via Talos API.

Data structure is sent over the channel each interval.

func (*Data) CalculateDiff

func (data *Data) CalculateDiff(oldData *Data)

CalculateDiff with data from previous iteration.

type Node

type Node struct {
	// These fields are directly API responses.
	Hostname    *machine.Hostname
	LoadAvg     *machine.LoadAvg
	Version     *machine.Version
	Memory      *machine.Memory
	SystemStat  *machine.SystemStat
	CPUsInfo    *machine.CPUsInfo
	NetDevStats *machine.NetworkDeviceStats
	DiskStats   *machine.DiskStats
	Processes   *machine.Process
	ServiceList *machine.ServiceList

	// These fields are calculated as diff with Node data from previous pol.
	SystemStatDiff  *machine.SystemStat
	NetDevStatsDiff *machine.NetworkDeviceStats
	DiskStatsDiff   *machine.DiskStats
	ProcsDiff       map[int32]*machine.ProcessInfo

	// Time-series data.
	Series map[string][]float64
}

Node represents data gathered from a single node.

func (*Node) CPUUsageByName

func (node *Node) CPUUsageByName(name string) float64

CPUUsageByName returns CPU usage by name.

func (*Node) CtxSwitches

func (node *Node) CtxSwitches() uint64

CtxSwitches returns diff of context switches.

func (*Node) MemUsage

func (node *Node) MemUsage() float64

MemUsage as used/total.

func (*Node) ProcsCreated

func (node *Node) ProcsCreated() uint64

ProcsCreated returns diff of processes created.

func (*Node) UpdateDiff

func (node *Node) UpdateDiff(old *Node)

UpdateDiff calculates diff with node data from previous iteration.

func (*Node) UpdateSeries

func (node *Node) UpdateSeries(old *Node)

UpdateSeries builds time-series data based on previous iteration data.

type Source

type Source struct {
	*client.Client

	Interval time.Duration
	// contains filtered or unexported fields
}

Source is a data source that gathers information about a Talos node using Talos API.

func (*Source) Run

func (source *Source) Run(ctx context.Context) <-chan *Data

Run the data poll on interval.

func (*Source) Stop

func (source *Source) Stop()

Stop the data collection process.

Jump to

Keyboard shortcuts

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