Documentation
¶
Overview ¶
Package metrics provides read-only Linux system telemetry snapshots.
Index ¶
- Variables
- func ValidateProcessIdentity(identity ProcessIdentity) error
- type BatterySnapshot
- type BatteryState
- type BlockDevice
- type BlockRates
- type BlockSampler
- type BlockSnapshot
- type CPUCore
- type CPUSampler
- type CPUSnapshot
- type CPUUsage
- type Capacity
- type Filesystem
- type FilesystemSnapshot
- type GPU
- type GPUSnapshot
- type GPUUsage
- type Issue
- type MemorySnapshot
- type NetworkInterface
- type NetworkRates
- type NetworkSampler
- type NetworkSnapshot
- type Process
- type ProcessIdentity
- type ProcessSampler
- type ProcessSnapshot
- type ThermalSnapshot
- type UptimeSnapshot
Constants ¶
This section is empty.
Variables ¶
var ErrProcessIdentityChanged = errors.New("process identity changed")
ErrProcessIdentityChanged means a PID now identifies a different process.
Functions ¶
func ValidateProcessIdentity ¶ added in v0.4.0
func ValidateProcessIdentity(identity ProcessIdentity) error
ValidateProcessIdentity confirms that identity still names the same process.
Types ¶
type BatterySnapshot ¶ added in v0.2.0
type BatterySnapshot struct {
CollectedAt time.Time
Present bool
Charge float64 // 0..1
ChargeValid bool
State BatteryState
EnergyJoules float64
RateWatts float64
RateValid bool
TimeRemaining time.Duration
TimeValid bool
Issues []Issue
}
BatterySnapshot is the aggregate battery observation. Present is false on a machine with no battery; that is not an error.
func ReadBattery ¶ added in v0.2.0
func ReadBattery() (BatterySnapshot, error)
ReadBattery collects the current aggregate battery. It prefers sysfs power-supply devices of type Battery or UPS. A machine with none reports Present false.
type BatteryState ¶ added in v0.2.0
type BatteryState uint8
BatteryState is the charging state of the aggregate battery.
const ( BatteryUnknown BatteryState = iota BatteryCharging BatteryDischarging BatteryFull )
type BlockDevice ¶
type BlockDevice struct {
Name string
Major uint32
Minor uint32
ReadBytes uint64
WriteBytes uint64
ReadOperations uint64
WriteOperations uint64
Busy time.Duration
Rates BlockRates
}
BlockDevice contains cumulative counters and derived rates for one block device.
type BlockRates ¶
type BlockRates struct {
ReadBytesPerSecond float64
WriteBytesPerSecond float64
ReadOperationsPerSecond float64
WriteOperationsPerSecond float64
BusyFraction float64
Valid bool
}
BlockRates contains rates derived from two block-device observations. Valid distinguishes observed zero rates from unavailable derived values.
type BlockSampler ¶
type BlockSampler struct {
// contains filtered or unexported fields
}
BlockSampler retains previous block counters for sequential rate sampling.
func NewBlockSampler ¶
func NewBlockSampler() *BlockSampler
NewBlockSampler returns a block sampler owned by one sequential polling caller.
func (*BlockSampler) Sample ¶
func (s *BlockSampler) Sample() (BlockSnapshot, error)
Sample returns one block-device snapshot. The sampler is not safe for concurrent use.
type BlockSnapshot ¶
type BlockSnapshot struct {
CollectedAt time.Time
Devices []BlockDevice
Issues []Issue
}
BlockSnapshot contains block-device data collected at one time. Devices and Issues are caller-owned snapshot slices.
type CPUSampler ¶
type CPUSampler struct {
// contains filtered or unexported fields
}
CPUSampler retains the previous CPU counters for sequential rate sampling.
func NewCPUSampler ¶
func NewCPUSampler() *CPUSampler
NewCPUSampler returns a CPU sampler owned by one sequential polling caller.
func (*CPUSampler) Sample ¶
func (s *CPUSampler) Sample() (CPUSnapshot, error)
Sample returns one CPU snapshot. The sampler is not safe for concurrent use.
type CPUSnapshot ¶
type CPUSnapshot struct {
CollectedAt time.Time
Usage CPUUsage
Cores []CPUCore
Load1 float64
Load5 float64
Load15 float64
LoadValid bool
Issues []Issue
}
CPUSnapshot contains aggregate and per-core CPU data collected at one time. Cores and Issues are caller-owned snapshot slices.
type CPUUsage ¶
CPUUsage contains a utilization fraction. Valid distinguishes an observed zero from no sample.
type Filesystem ¶
type Filesystem struct {
MountID uint64
MountPoint string
Source string
Type string
ReadOnly bool
Capacity Capacity
}
Filesystem contains one mounted filesystem and its byte capacity.
type FilesystemSnapshot ¶
type FilesystemSnapshot struct {
CollectedAt time.Time
Filesystems []Filesystem
Issues []Issue
}
FilesystemSnapshot contains mounted filesystem data collected at one time. Filesystems and Issues are caller-owned snapshot slices.
func ReadFilesystems ¶
func ReadFilesystems() (FilesystemSnapshot, error)
ReadFilesystems returns one mounted-filesystem snapshot from Linux.
type GPU ¶ added in v0.3.0
type GPU struct {
PCIID string
Driver string
Name string
Usage GPUUsage
Celsius float64
TempValid bool
}
GPU is one display device.
type GPUSnapshot ¶ added in v0.3.0
GPUSnapshot lists GPUs collected at one time. GPUs and Issues are caller-owned.
func ReadGPU ¶ added in v0.3.0
func ReadGPU() (GPUSnapshot, error)
ReadGPU collects usage and temperature for each discrete or integrated GPU.
type GPUUsage ¶ added in v0.3.0
GPUUsage is a 0..1 busy fraction. Valid distinguishes a real zero from no sample.
type MemorySnapshot ¶
MemorySnapshot contains memory and swap byte capacities collected at one time.
func ReadMemory ¶
func ReadMemory() (MemorySnapshot, error)
ReadMemory returns one memory and swap snapshot from Linux.
type NetworkInterface ¶
type NetworkInterface struct {
Name string
Index uint32
ReceiveBytes uint64
ReceivePackets uint64
ReceiveErrors uint64
ReceiveDropped uint64
TransmitBytes uint64
TransmitPackets uint64
TransmitErrors uint64
TransmitDropped uint64
Rates NetworkRates
}
NetworkInterface contains cumulative counters and derived rates for one interface.
type NetworkRates ¶
type NetworkRates struct {
ReceiveBytesPerSecond float64
TransmitBytesPerSecond float64
ReceivePacketsPerSecond float64
TransmitPacketsPerSecond float64
Valid bool
}
NetworkRates contains rates derived from two network observations. Valid distinguishes observed zero rates from unavailable derived values.
type NetworkSampler ¶
type NetworkSampler struct {
// contains filtered or unexported fields
}
NetworkSampler retains previous interface counters for sequential rate sampling.
func NewNetworkSampler ¶
func NewNetworkSampler() *NetworkSampler
NewNetworkSampler returns a network sampler owned by one sequential polling caller.
func (*NetworkSampler) Sample ¶
func (s *NetworkSampler) Sample() (NetworkSnapshot, error)
Sample returns one network-interface snapshot. The sampler is not safe for concurrent use.
type NetworkSnapshot ¶
type NetworkSnapshot struct {
CollectedAt time.Time
Interfaces []NetworkInterface
Issues []Issue
}
NetworkSnapshot contains network-interface data collected at one time. Interfaces and Issues are caller-owned snapshot slices.
type Process ¶ added in v0.4.0
type Process struct {
Identity ProcessIdentity
Name string
ParentPID int
UID uint32
UIDValid bool
ResidentBytes uint64
ResidentValid bool
Args []string
CPU CPUUsage
}
Process contains one process observation and its best-effort derived CPU usage.
type ProcessIdentity ¶ added in v0.4.0
ProcessIdentity distinguishes a process from a later process that reuses its PID.
type ProcessSampler ¶ added in v0.4.0
type ProcessSampler struct {
// contains filtered or unexported fields
}
ProcessSampler retains previous process and aggregate CPU counters for sequential rate sampling.
func NewProcessSampler ¶ added in v0.4.0
func NewProcessSampler() *ProcessSampler
NewProcessSampler returns a process sampler owned by one sequential polling caller.
func (*ProcessSampler) Sample ¶ added in v0.4.0
func (s *ProcessSampler) Sample() (ProcessSnapshot, error)
Sample returns one process snapshot. The sampler is not safe for concurrent use.
type ProcessSnapshot ¶ added in v0.4.0
ProcessSnapshot contains processes collected at one time. Processes, Args, and Issues are caller-owned snapshot slices.
type ThermalSnapshot ¶ added in v0.3.0
type ThermalSnapshot struct {
CollectedAt time.Time
Celsius float64
Valid bool
Source string
Issues []Issue
}
ThermalSnapshot is one scored CPU package temperature in Celsius. Valid is false when no known sensor exists; that is not an error.
func ReadThermal ¶ added in v0.3.0
func ReadThermal() (ThermalSnapshot, error)
ReadThermal collects the current CPU package temperature.
type UptimeSnapshot ¶
UptimeSnapshot contains uptime as a duration collected at one time.
func ReadUptime ¶
func ReadUptime() (UptimeSnapshot, error)
ReadUptime returns one uptime snapshot from Linux.