Documentation
¶
Overview ¶
Package metrics provides read-only Linux system telemetry snapshots.
Index ¶
- 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 Issue
- type MemorySnapshot
- type NetworkInterface
- type NetworkRates
- type NetworkSampler
- type NetworkSnapshot
- type UptimeSnapshot
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
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 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 UptimeSnapshot ¶
UptimeSnapshot contains uptime as a duration collected at one time.
func ReadUptime ¶
func ReadUptime() (UptimeSnapshot, error)
ReadUptime returns one uptime snapshot from Linux.