Help us shape the future of Go! Take the 2026 Go Developer Survey

hoststats

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Mar 19, 2025 License: MPL-2.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var Gauges = []prometheus.GaugeDefinition{
	{
		Name: []string{"host", "memory", "total"},
		Help: "Total physical memory in bytes",
	},
	{
		Name: []string{"host", "memory", "available"},
		Help: "Available physical memory in bytes",
	},
	{
		Name: []string{"host", "memory", "free"},
		Help: "Free physical memory in bytes",
	},
	{
		Name: []string{"host", "memory", "used"},
		Help: "Used physical memory in bytes",
	},
	{
		Name: []string{"host", "memory", "used_percent"},
		Help: "Percentage of physical memory in use",
	},
	{
		Name: []string{"host", "cpu", "total"},
		Help: "Total cpu utilization",
	},
	{
		Name: []string{"host", "cpu", "user"},
		Help: "User cpu utilization",
	},
	{
		Name: []string{"host", "cpu", "idle"},
		Help: "Idle cpu utilization",
	},
	{
		Name: []string{"host", "cpu", "iowait"},
		Help: "Iowait cpu utilization",
	},
	{
		Name: []string{"host", "cpu", "system"},
		Help: "System cpu utilization",
	},
	{
		Name: []string{"host", "disk", "size"},
		Help: "Size of disk in bytes",
	},
	{
		Name: []string{"host", "disk", "used"},
		Help: "Disk usage in bytes",
	},
	{
		Name: []string{"host", "disk", "available"},
		Help: "Available bytes on disk",
	},
	{
		Name: []string{"host", "disk", "used_percent"},
		Help: "Percentage of disk space usage",
	},
	{
		Name: []string{"host", "disk", "inodes_percent"},
		Help: "Percentage of disk inodes usage",
	},
	{
		Name: []string{"host", "uptime"},
		Help: "System uptime",
	},
}

Functions

This section is empty.

Types

type CPUStats

type CPUStats struct {
	CPU    string
	User   float64
	System float64
	Idle   float64
	Iowait float64
	Total  float64
}

CPUStats represents hoststats related to cpu usage

type Collector

type Collector struct {
	// contains filtered or unexported fields
}

Collector collects host resource usage stats

func NewCollector

func NewCollector(ctx context.Context, logger hclog.Logger, dataDir string, opts ...CollectorOption) *Collector

NewCollector returns a Collector. The dataDir is passed in so that we can present the disk related statistics for the mountpoint where the dataDir exists

func (*Collector) Stats

func (c *Collector) Stats() *HostStats

Stats returns the host stats that has been collected

type CollectorOption

type CollectorOption func(c *Collector)

func WithBaseLabels

func WithBaseLabels(labels []metrics.Label) CollectorOption

func WithMetrics

func WithMetrics(m *metrics.Metrics) CollectorOption

type DiskStats

type DiskStats struct {
	Path              string
	Size              uint64
	Used              uint64
	Available         uint64
	UsedPercent       float64
	InodesUsedPercent float64
}

DiskStats represents hoststats related to disk usage

type HostStats

type HostStats struct {
	Memory       *MemoryStats
	CPU          []*CPUStats
	DataDirStats *DiskStats
	Uptime       uint64
	Timestamp    int64
}

HostStats represents resource usage hoststats of the host running a Consul agent

func (*HostStats) Clone

func (hs *HostStats) Clone() *HostStats

func (*HostStats) Emit

func (hs *HostStats) Emit(sink Metrics, baseLabels []metrics.Label)

type MemoryStats

type MemoryStats struct {
	Total       uint64
	Available   uint64
	Used        uint64
	UsedPercent float64
	Free        uint64
}

MemoryStats represents hoststats related to virtual memory usage

type Metrics

type Metrics interface {
	SetGaugeWithLabels(key []string, val float32, labels []metrics.Label)
}

Metrics defines an interface for the methods used to emit data to the go-metrics library. `metrics.Default()` should always satisfy this interface.

Jump to

Keyboard shortcuts

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