metrics

package
v1.0.40 Latest Latest
Warning

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

Go to latest
Published: Nov 17, 2026 License: MIT Imports: 20 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Budget added in v1.0.40

type Budget struct {
	Known  bool
	Value  int64
	Reason string
}

Budget is a measured resource budget or an explicit unknown state. Value is bytes for byte budgets and a free-inode count for inode budgets.

type Collector

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

Collects server metrics in the background

func NewCollector

func NewCollector(store *storage.Store, dockerCli *docker.Client, sender *command.Sender, cfg *config.Config, bus *events.Bus, log *logger.Logger, collectorCfg ...CollectorConfig) *Collector

Creates a new metrics collector

func NewCollectorWithPool

func NewCollectorWithPool(store *storage.Store, dockerCli *docker.Client, pool *docker.ClientPool, sender *command.Sender, cfg *config.Config, bus *events.Bus, log *logger.Logger, collectorCfg ...CollectorConfig) *Collector

NewCollectorWithPool creates a new metrics collector with a multi-node ClientPool. If pool is nil and dockerCli is non-nil, a single-node pool wrapping dockerCli is created.

func (*Collector) GetAllMetrics

func (c *Collector) GetAllMetrics() map[string]*ServerMetrics

Gets a copy of all metrics

func (*Collector) GetMetrics

func (c *Collector) GetMetrics(serverID string) *ServerMetrics

Get metrics for a specific server

func (*Collector) PruneStale

func (c *Collector) PruneStale(maxAge time.Duration) int

PruneStale evicts entries not updated within maxAge (MINE-144 retention). Returns evicted count.

func (*Collector) RemoveMetrics

func (c *Collector) RemoveMetrics(serverID string)

Removes metrics for a server on delete

func (*Collector) SeedMetrics added in v1.0.40

func (c *Collector) SeedMetrics(m ServerMetrics)

SeedMetrics installs an already-collected metrics row. Health reads SLP and RCON timestamps from it and does not ping the game itself.

func (*Collector) SetImageDiskUsageReader added in v1.0.40

func (c *Collector) SetImageDiskUsageReader(r ImageDiskUsageReader)

SetImageDiskUsageReader wires Docker image-store measurement for a node. When unset, image cache is reported as unknown with a stable reason.

func (*Collector) Start

func (c *Collector) Start() error

Start background metrics collection

func (*Collector) Stop

func (c *Collector) Stop()

Stop background metrics collection

type CollectorConfig

type CollectorConfig struct {
	StatsInterval time.Duration // default 5s
	RCONInterval  time.Duration // default 10s
	DiskInterval  time.Duration // default 60s
	SLPInterval   time.Duration // default 15s
	SLPTimeout    time.Duration // default 5s
	SLPEnabled    bool          // default true
}

Configuration for metrics collector

func DefaultConfig

func DefaultConfig() CollectorConfig

Get default collector configuration

type ImageDiskUsageReader added in v1.0.40

type ImageDiskUsageReader interface {
	ImageStoreBytes(ctx context.Context, nodeID string) (int64, error)
}

ImageDiskUsageReader measures Docker image-store bytes on a node.

type ServerMetrics

type ServerMetrics struct {
	ServerID    string
	CPUPercent  float64
	MemoryUsage float64 // MB
	DiskUsage   int64   // bytes (total server data)
	DiskTotal   int64   // bytes
	WorldSize   int64   // bytes (world directory only); storage.world_quota_mb admits against this
	// Separate resource budgets (OSS-239). These are measured or explicitly
	// unknown; they are not a hard world quota and must not be inferred from
	// DiskUsage or WorldSize.
	WorldFreeInodes          Budget
	WorldFilesystemFreeBytes Budget
	BackupStagingBytes       Budget
	ImageCacheBytes          Budget
	PlayersOnline            int
	TPS                      float64
	LastUpdated              time.Time

	// SLP fields
	SLPAvailable    bool
	SLPLatencyMs    int64
	MOTD            string
	ServerVersion   string
	ProtocolVersion int
	PlayerSample    []string
	MaxPlayers      int
	Favicon         string // Base64 PNG (data:image/png;base64,...)
	SLPLastUpdated  time.Time
	// RCONLastUpdated is when a list or TPS command last succeeded. It is
	// not set on failure, so a missing timestamp stays unknown.
	RCONLastUpdated time.Time
}

Jump to

Keyboard shortcuts

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