collector

package
v0.0.0-...-a6686b8 Latest Latest
Warning

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

Go to latest
Published: Jul 15, 2026 License: Apache-2.0 Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type CPUCoreStat

type CPUCoreStat struct {
	CPU string
	CPUStat
}

type CPUStat

type CPUStat struct {
	User   float64
	System float64
	Wait   float64
	Idle   float64
}

type Collector

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

Collector aggregates the system-metrics snapshot for a single VM.

Concurrency: Collect is intended to be called from a single goroutine. prevTimesStat and prevCoreStats are mutated in place by Collect and have no synchronization; clockDriftErrors is the lone exception (touched via atomic.AddUint64 / LoadUint64) so a future caller reading the running total from another goroutine still sees a consistent value.

func New

func New(log *log.Logger, opts ...CollectorOption) Collector

func (*Collector) Collect

func (c *Collector) Collect() (SystemStat, error)

type CollectorOption

type CollectorOption func(*Collector)

func WithClockSource

func WithClockSource(ts clockdrift.TimeSource) CollectorOption

WithClockSource overrides the default chronyc-on-PATH discovery used by New. Pass a stub TimeSource in tests to make outcomes deterministic regardless of whether the host has chronyc installed.

Passing nil is a no-op (auto-discovery still runs); use WithoutClockSource to disable clock drift collection explicitly.

func WithRawCollector

func WithRawCollector(c RawCollector) CollectorOption

func WithoutClockSource

func WithoutClockSource() CollectorOption

WithoutClockSource disables clock drift collection entirely, bypassing the default chronyc-on-PATH discovery. The collector emits no clock_drift_* metrics and reports ClockDriftEnabled == false.

type DiskStat

type DiskStat struct {
	Present bool

	Percent      float64
	InodePercent float64
	ReadBytes    uint64
	WriteBytes   uint64
	ReadTime     uint64
	WriteTime    uint64
	IOTime       uint64
}

type HealthStat

type HealthStat struct {
	Present bool
	Healthy bool
}

type InputFunc

type InputFunc func() (SystemStat, error)

type NetworkStat

type NetworkStat struct {
	Name            string
	BytesSent       uint64
	BytesReceived   uint64
	PacketsSent     uint64
	PacketsReceived uint64
	ErrIn           uint64
	ErrOut          uint64
	DropIn          uint64
	DropOut         uint64
}

type Processor

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

func NewProcessor

func NewProcessor(
	in InputFunc,
	senders []StatsSender,
	interval time.Duration,
	log *log.Logger,
) *Processor

func (*Processor) Run

func (p *Processor) Run()

type ProtoCountersStat

type ProtoCountersStat struct {
	Present bool

	IPForwarding    int64
	UDPNoPorts      int64
	UDPInErrors     int64
	UDPLiteInErrors int64

	TCPActiveOpens int64
	TCPCurrEstab   int64
	TCPRetransSegs int64
}

type RawCollector

type RawCollector interface {
	ProtoCountersWithContext(context.Context, []string) ([]net.ProtoCountersStat, error)
	VirtualMemoryWithContext(context.Context) (*mem.VirtualMemoryStat, error)
	SwapMemoryWithContext(context.Context) (*mem.SwapMemoryStat, error)
	AvgWithContext(context.Context) (*load.AvgStat, error)
	TimesWithContext(context.Context, bool) ([]cpu.TimesStat, error)
	PhysicalCores(context.Context) (int, error)
	UsageWithContext(context.Context, string) (*disk.UsageStat, error)
	NetIOCountersWithContext(context.Context, bool) ([]net.IOCountersStat, error)
	DiskIOCountersWithContext(context.Context, ...string) (map[string]disk.IOCountersStat, error)
	PartitionsWithContext(context.Context, bool) ([]disk.PartitionStat, error)
	InstanceHealth() ([]byte, error)
}

type StatsSender

type StatsSender interface {
	Send(SystemStat)
}

type SystemStat

type SystemStat struct {
	CPUStat
	CPUCoreStats         []CPUCoreStat
	CPUPhysicalCoreCount int
	CPUThreadsPerCore    int

	MemKB      uint64
	MemPercent float64

	SwapKB      uint64
	SwapPercent float64

	Load1M  float64
	Load5M  float64
	Load15M float64

	SystemDisk     DiskStat
	EphemeralDisk  DiskStat
	PersistentDisk DiskStat

	ProtoCounters ProtoCountersStat

	Networks []NetworkStat

	Health HealthStat

	ClockDrift            *clockdrift.TimeSyncData
	ClockDriftEnabled     bool
	ClockDriftErrorsTotal uint64
}

Directories

Path Synopsis
Package clockdrift collects NTP/chrony time-synchronization data from the host for emission as PCI-DSS 10.6 audit evidence.
Package clockdrift collects NTP/chrony time-synchronization data from the host for emission as PCI-DSS 10.6 audit evidence.

Jump to

Keyboard shortcuts

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