metrics

package
v0.0.3 Latest Latest
Warning

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

Go to latest
Published: Jan 25, 2026 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type BatteryInfo added in v0.0.3

type BatteryInfo struct {
	Percent  float64 `json:"percent"`
	Charging bool    `json:"charging"`
}

BatteryInfo holds battery status (nil on desktops or if unavailable)

type LoadAverages added in v0.0.3

type LoadAverages struct {
	Load1  float64 `json:"load1"`
	Load5  float64 `json:"load5"`
	Load15 float64 `json:"load15"`
}

LoadAverages holds Unix-style load averages (nil on Windows)

type NetworkIO added in v0.0.3

type NetworkIO struct {
	BytesSent uint64 `json:"bytes_sent"`
	BytesRecv uint64 `json:"bytes_recv"`
}

NetworkIO holds network traffic counters

type Snapshot

type Snapshot struct {
	Timestamp     time.Time     `json:"timestamp"`
	Uptime        time.Duration `json:"uptime"`
	MemoryTotal   uint64        `json:"memory_total"`
	MemoryUsed    uint64        `json:"memory_used"`
	MemoryPercent float64       `json:"memory_percent"`
	CPUPercent    float64       `json:"cpu_percent"`
	DiskTotal     uint64        `json:"disk_total"`
	DiskUsed      uint64        `json:"disk_used"`
	DiskPercent   float64       `json:"disk_percent"`

	// Optional metrics (nil if unavailable on platform)
	LoadAverages *LoadAverages `json:"load_averages,omitempty"`
	SwapTotal    *uint64       `json:"swap_total,omitempty"`
	SwapUsed     *uint64       `json:"swap_used,omitempty"`
	SwapPercent  *float64      `json:"swap_percent,omitempty"`
	Battery      *BatteryInfo  `json:"battery,omitempty"`
	ProcessCount *int          `json:"process_count,omitempty"`
	NetworkIO    *NetworkIO    `json:"network_io,omitempty"`
}

Snapshot represents a moment-in-time capture of system state

func Gather

func Gather() (*Snapshot, error)

Gather collects current system metrics and returns a snapshot

func SnapshotFromJSON added in v0.0.2

func SnapshotFromJSON(data string) (*Snapshot, error)

SnapshotFromJSON deserializes a snapshot from a JSON string

func (*Snapshot) ToJSON added in v0.0.2

func (s *Snapshot) ToJSON() (string, error)

ToJSON serializes the snapshot to a JSON string

Jump to

Keyboard shortcuts

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