metrics

package
v0.0.0-...-2759aa6 Latest Latest
Warning

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

Go to latest
Published: May 27, 2022 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

View Source
const (
	B  ByteSize = 1
	KB          = B << 10
	MB          = KB << 10
	GB          = MB << 10
	TB          = GB << 10
	PB          = TB << 10
	EB          = PB << 10
)

Constants for ByteSize.

Variables

View Source
var Gatherer gatherer = &SystemGatherer{}

Gatherer is the interface to collect metrics, which can be changed to mock in tests.

Functions

This section is empty.

Types

type ByteSize

type ByteSize uint64

ByteSize represents a size in bytes.

func (ByteSize) EB

func (b ByteSize) EB() float64

EB returns the size in exabytes.

func (ByteSize) GB

func (b ByteSize) GB() float64

GB returns the size in gigabytes.

func (ByteSize) KB

func (b ByteSize) KB() float64

KB returns the size in kilobytes.

func (ByteSize) MB

func (b ByteSize) MB() float64

MB returns the size in megabytes.

func (ByteSize) PB

func (b ByteSize) PB() float64

PB returns the size in petabytes.

func (ByteSize) String

func (b ByteSize) String() string

String returns the size in human readable format.

func (ByteSize) TB

func (b ByteSize) TB() float64

TB returns the size in terabytes.

type ContainerStatsJSON

type ContainerStatsJSON struct {
	Name string `json:"name"`
	ID   string `json:"id"`

	MemoryUsed      uint64  `json:"memory_used"`
	MemoryAvailable uint64  `json:"memory_available"`
	MemoryUsage     float64 `json:"memory_usage"` // percentage

	CPUCount       int     `json:"cpu_count"`
	CPUDelta       uint64  `json:"cpu_delta"`
	CPUSystemDelta uint64  `json:"cpu_system_delta"`
	CPUUsage       float64 `json:"cpu_usage"` // percentage
}

type Metrics

type Metrics struct {
	SystemMetrics     *SystemMetrics        `json:"system_metrics"`
	ContainersMetrics []*ContainerStatsJSON `json:"containers_metrics"`
}

Metrics holds the metrics about docker and the system.

func Gather

func Gather() (*Metrics, error)

Gather gathers metrics from docker and the system.

type SystemGatherer

type SystemGatherer struct{}

SystemGatherer collects metrics

func (*SystemGatherer) Gather

func (s *SystemGatherer) Gather() (*Metrics, error)

Gather gathers metrics from docker and the system.

type SystemMetrics

type SystemMetrics struct {
	Uptime time.Duration `json:"uptime"`

	MemoryTotal ByteSize `json:"memory_total"`
	MemoryUsed  ByteSize `json:"memory_used"`
	MemoryFree  ByteSize `json:"memory_free"`

	CPUCount int `json:"cpu_count"`

	CPUUser   float64 `json:"cpu_user"`
	CPUSystem float64 `json:"cpu_system"`
	CPUIdle   float64 `json:"cpu_idle"`
}

SystemMetrics holds the metrics about the system.

type TestGatherer

type TestGatherer struct {
	Metrics *Metrics
}

TestGatherer is a mock gatherer for tests.

func (TestGatherer) Gather

func (t TestGatherer) Gather() (*Metrics, error)

Gather returns the metrics set while testing.

Jump to

Keyboard shortcuts

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