metrics

package
v1.0.39 Latest Latest
Warning

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

Go to latest
Published: Oct 28, 2026 License: MIT Imports: 17 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

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) 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 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)
	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
}

Jump to

Keyboard shortcuts

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