metrics

package
v0.0.7 Latest Latest
Warning

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

Go to latest
Published: Jan 31, 2026 License: MIT Imports: 13 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 FanInfo added in v0.0.5

type FanInfo struct {
	Speed float64 `json:"speed"` // RPM
	Name  string  `json:"name"`  // Fan identifier
}

FanInfo holds fan speed readings

type GPUInfo added in v0.0.5

type GPUInfo struct {
	Usage       *float64 `json:"usage,omitempty"`        // GPU utilization percent
	MemoryUsed  *uint64  `json:"memory_used,omitempty"`  // VRAM used in bytes
	MemoryTotal *uint64  `json:"memory_total,omitempty"` // Total VRAM in bytes
}

GPUInfo holds GPU metrics

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 MachineType added in v0.0.5

type MachineType string

MachineType represents the type of machine

const (
	MachineTypeLaptop    MachineType = "laptop"
	MachineTypeDesktop   MachineType = "desktop"
	MachineTypeServer    MachineType = "server"
	MachineTypeVM        MachineType = "virtual_machine"
	MachineTypeContainer MachineType = "container"
	MachineTypeUnknown   MachineType = "unknown"
)

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 PlatformInfo added in v0.0.5

type PlatformInfo struct {
	OS           string `json:"os"`           // darwin, linux, windows
	Architecture string `json:"architecture"` // amd64, arm64
	OSVersion    string `json:"os_version"`   // e.g., "14.0" for macOS Sonoma
	Kernel       string `json:"kernel"`       // kernel version
}

PlatformInfo holds OS and architecture info

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"`

	// Machine identity
	MachineType MachineType   `json:"machine_type"`
	Platform    *PlatformInfo `json:"platform,omitempty"`
	TimeOfDay   TimeOfDay     `json:"time_of_day"`

	// 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"`
	Thermal      *ThermalInfo  `json:"thermal,omitempty"`
	Fans         []*FanInfo    `json:"fans,omitempty"`
	GPU          *GPUInfo      `json:"gpu,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

type ThermalInfo added in v0.0.5

type ThermalInfo struct {
	CPUTemp     *float64 `json:"cpu_temp,omitempty"` // Celsius
	GPUTemp     *float64 `json:"gpu_temp,omitempty"` // Celsius
	HighestTemp float64  `json:"highest_temp"`       // Highest sensor reading
	SensorCount int      `json:"sensor_count"`       // Number of sensors read
}

ThermalInfo holds temperature readings

type TimeOfDay added in v0.0.5

type TimeOfDay string

TimeOfDay represents the general time period

const (
	TimeOfDayNight     TimeOfDay = "night"     // 12am - 6am
	TimeOfDayMorning   TimeOfDay = "morning"   // 6am - 12pm
	TimeOfDayAfternoon TimeOfDay = "afternoon" // 12pm - 6pm
	TimeOfDayEvening   TimeOfDay = "evening"   // 6pm - 12am
)

Jump to

Keyboard shortcuts

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