system

package
v0.21.1 Latest Latest
Warning

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

Go to latest
Published: Oct 22, 2026 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Battery added in v0.19.0

type Battery [2]uint8

Battery stores the representative battery's percent and charge state. Its custom JSON encoding keeps the public and persisted representation as a numeric tuple under both encoding/json v1 and v2.

func (Battery) MarshalJSON added in v0.19.0

func (b Battery) MarshalJSON() ([]byte, error)

type CombinedData

type CombinedData struct {
	Stats           Stats              `json:"stats" cbor:"0,keyasint"`
	Info            Info               `json:"info" cbor:"1,keyasint"`
	Containers      []*container.Stats `json:"container" cbor:"2,keyasint"`
	SystemdServices []*systemd.Service `json:"systemd,omitempty" cbor:"3,keyasint,omitempty"`
	Details         *Details           `cbor:"4,keyasint,omitempty"`
	// SystemdServicesUpdated distinguishes a fresh empty snapshot from a response
	// that omitted systemd data (for example, a short-cache dashboard request).
	SystemdServicesUpdated bool                      `json:"systemdUpdated,omitzero" cbor:"5,keyasint,omitempty"`
	Monitors               map[string]monitor.Result `cbor:"6,keyasint"`
}

Final data structure to return to the hub

type ConnectionType added in v0.12.10

type ConnectionType = uint8
const (
	ConnectionTypeNone ConnectionType = iota
	ConnectionTypeSSH
	ConnectionTypeWebSocket
)

type Details added in v0.18.0

type Details struct {
	Hostname      string        `cbor:"0,keyasint"`
	Kernel        string        `cbor:"1,keyasint,omitempty"`
	Cores         int           `cbor:"2,keyasint"`
	Threads       int           `cbor:"3,keyasint"`
	CpuModel      string        `cbor:"4,keyasint"`
	Os            Os            `cbor:"5,keyasint"`
	OsName        string        `cbor:"6,keyasint"`
	Arch          string        `cbor:"7,keyasint"`
	Podman        bool          `cbor:"8,keyasint,omitempty"`
	MemoryTotal   uint64        `cbor:"9,keyasint"`
	SmartInterval time.Duration `cbor:"10,keyasint,omitempty"`
	ZfsInterval   time.Duration `cbor:"11,keyasint,omitempty"` // interval for ZFS detail refresh
	Sockets       int           `cbor:"12,keyasint,omitempty"` // physical CPU packages, 0 if unknown
}

Data that does not change during process lifetime and is not needed in All Systems table

type FsStats

type FsStats struct {
	Root              bool       `json:"-"`
	Mountpoint        string     `json:"-"`
	Name              string     `json:"-"`
	DiskTotal         float64    `json:"d" cbor:"0,keyasint"`
	DiskUsed          float64    `json:"du" cbor:"1,keyasint"`
	TotalRead         uint64     `json:"tr,omitzero" cbor:"9,keyasint,omitzero"`  // cumulative device read bytes
	TotalWrite        uint64     `json:"tw,omitzero" cbor:"10,keyasint,omitzero"` // cumulative device write bytes
	DiskReadPs        float64    `json:"r,omitzero" cbor:"2,keyasint,omitzero"`   // Deprecated: sent by agents < 0.13.0. Migrated to DiskReadBytes/DiskWriteBytes by the hub.
	DiskWritePs       float64    `json:"w,omitzero" cbor:"3,keyasint,omitzero"`   // Deprecated: sent by agents < 0.13.0. Migrated to DiskReadBytes/DiskWriteBytes by the hub.
	DiskReadBytes     uint64     `json:"rb" cbor:"6,keyasint,omitempty"`
	DiskWriteBytes    uint64     `json:"wb" cbor:"7,keyasint,omitempty"`
	MaxDiskReadBytes  uint64     `json:"rbm,omitzero" cbor:"-"`
	MaxDiskWriteBytes uint64     `json:"wbm,omitzero" cbor:"-"`
	DiskIoStats       [6]float64 `json:"dios,omitzero" cbor:"8,keyasint,omitzero"` // [read time %, write time %, io utilization %, r_await ms, w_await ms, weighted io %]
	MaxDiskIoStats    [6]float64 `json:"diosm,omitzero" cbor:"-"`                  // max values for DiskIoStats
}

type GPUData

type GPUData struct {
	Name        string             `json:"n" cbor:"0,keyasint"`
	Temperature float64            `json:"-"`
	MemoryUsed  float64            `json:"mu,omitzero" cbor:"1,keyasint,omitempty,omitzero"`
	MemoryTotal float64            `json:"mt,omitzero" cbor:"2,keyasint,omitempty,omitzero"`
	Usage       float64            `json:"u" cbor:"3,keyasint,omitempty"`
	Power       float64            `json:"p,omitzero" cbor:"4,keyasint,omitempty"`
	Count       float64            `json:"-"`
	Engines     map[string]float64 `json:"e,omitempty" cbor:"5,keyasint,omitempty"`
	PowerPkg    float64            `json:"pp,omitzero" cbor:"6,keyasint,omitempty"`
}

type Info

type Info struct {
	Hostname      string `json:"h,omitempty" cbor:"0,keyasint,omitempty"` // deprecated - moved to Details struct
	KernelVersion string `json:"k,omitempty" cbor:"1,keyasint,omitempty"` // deprecated - moved to Details struct
	Cores         int    `json:"c,omitzero" cbor:"2,keyasint,omitzero"`   // deprecated - moved to Details struct
	// Threads is needed in Info struct to calculate load average thresholds
	Threads       int     `json:"t,omitzero" cbor:"3,keyasint,omitempty"`
	CpuModel      string  `json:"m,omitempty" cbor:"4,keyasint,omitempty"` // deprecated - moved to Details struct
	Uptime        uint64  `json:"u" cbor:"5,keyasint"`
	Cpu           float64 `json:"cpu" cbor:"6,keyasint"`
	MemPct        float64 `json:"mp" cbor:"7,keyasint"`
	DiskPct       float64 `json:"dp" cbor:"8,keyasint"`
	Bandwidth     float64 `json:"b,omitzero" cbor:"9,keyasint"` // deprecated in favor of BandwidthBytes
	AgentVersion  string  `json:"v" cbor:"10,keyasint"`
	Podman        bool    `json:"p,omitzero" cbor:"11,keyasint,omitempty"` // deprecated - moved to Details struct
	GpuPct        float64 `json:"g,omitzero" cbor:"12,keyasint,omitempty"`
	DashboardTemp float64 `json:"dt,omitzero" cbor:"13,keyasint,omitempty"`
	Os            Os      `json:"os,omitzero" cbor:"14,keyasint,omitempty"` // deprecated - moved to Details struct

	BandwidthBytes uint64             `json:"bb" cbor:"18,keyasint"`
	LoadAvg        [3]float64         `json:"la,omitempty" cbor:"19,keyasint"`
	ConnectionType ConnectionType     `json:"ct,omitzero" cbor:"20,keyasint,omitempty,omitzero"`
	ExtraFsPct     map[string]float64 `json:"efs,omitempty" cbor:"21,keyasint,omitempty"`
	Services       []uint16           `json:"sv,omitempty" cbor:"22,keyasint,omitempty"`  // [totalServices, numFailedServices]
	Battery        Battery            `json:"bat,omitzero" cbor:"23,keyasint,omitzero"`   // [percent, charge state]
	RootDiskName   string             `json:"rdn,omitempty" cbor:"24,keyasint,omitempty"` // custom name for root disk (set via FILESYSTEM=device__name)
	PackageUpdates []uint16           `json:"pu,omitempty" cbor:"25,keyasint,omitempty"`  // [totalUpdates, securityUpdates] (security omitted if unknown)
	WiFi           map[string]WiFi    `json:"wf,omitempty" cbor:"26,keyasint,omitempty"`  // connected Wi-Fi interfaces
	SystemdLogs    bool               `json:"jl,omitzero" cbor:"27,keyasint,omitempty"`   // agent can read the system journal
}

Core system data that is needed in All Systems table

type NetIoStats

type NetIoStats struct {
	BytesRecv uint64
	BytesSent uint64
	Time      time.Time
	Name      string
}

type Os

type Os = uint8
const (
	Linux Os = iota
	Darwin
	Windows
	Freebsd
)

type PackageUpdate added in v0.21.0

type PackageUpdate struct {
	Name      string `json:"name" cbor:"0,keyasint"`
	Current   string `json:"current,omitempty" cbor:"1,keyasint,omitempty"` // installed version, empty if unknown
	Available string `json:"available" cbor:"2,keyasint"`
	Security  bool   `json:"security,omitzero" cbor:"3,keyasint,omitempty"`
}

PackageUpdate is one pending package update on the host.

type PackageUpdates added in v0.21.0

type PackageUpdates struct {
	Manager string `json:"manager,omitempty" cbor:"0,keyasint,omitempty"`
	// CheckedAt is the Unix time in seconds of the last check, 0 if none has finished.
	CheckedAt int64 `json:"checkedAt,omitzero" cbor:"1,keyasint,omitempty"`
	// SecurityKnown is true if the package manager flags security updates per package.
	SecurityKnown bool            `json:"securityKnown,omitzero" cbor:"2,keyasint,omitempty"`
	Packages      []PackageUpdate `json:"packages" cbor:"3,keyasint"`
}

PackageUpdates is the detail payload returned by the agent for the GetPackageUpdates action. The counts in Info.PackageUpdates come from the same check.

type Stats

type Stats struct {
	Cpu            float64             `json:"cpu" cbor:"0,keyasint"`
	MaxCpu         float64             `json:"cpum,omitzero" cbor:"-"`
	Mem            float64             `json:"m" cbor:"2,keyasint"`  // Deprecated: GB, use MemBytes. Memory GB fields are kept for older hubs and integrations.
	MaxMem         float64             `json:"mm,omitzero" cbor:"-"` // Deprecated: GB, use MaxMemBytes.
	MemUsed        float64             `json:"mu" cbor:"3,keyasint"` // Deprecated: GB, use MemBytes.
	MemPct         float64             `json:"mp" cbor:"4,keyasint"`
	MemBuffCache   float64             `json:"mb" cbor:"5,keyasint"`                    // Deprecated: GB, use MemBytes.
	MemZfsArc      float64             `json:"mz,omitzero" cbor:"6,keyasint,omitempty"` // Deprecated: GB, use MemBytes.
	Swap           float64             `json:"s,omitzero" cbor:"7,keyasint,omitempty"`  // Deprecated: GB, use SwapBytes.
	SwapUsed       float64             `json:"su,omitzero" cbor:"8,keyasint,omitempty"` // Deprecated: GB, use SwapBytes.
	DiskTotal      float64             `json:"d" cbor:"9,keyasint"`
	DiskUsed       float64             `json:"du" cbor:"10,keyasint"`
	DiskPct        float64             `json:"dp" cbor:"11,keyasint"`
	DiskReadPs     float64             `json:"dr,omitzero" cbor:"12,keyasint,omitzero"` // Deprecated: sent by agents < 0.13.0. Migrated to DiskIO by the hub.
	DiskWritePs    float64             `json:"dw,omitzero" cbor:"13,keyasint,omitzero"` // Deprecated: sent by agents < 0.13.0. Migrated to DiskIO by the hub.
	NetworkSent    float64             `json:"ns,omitzero" cbor:"16,keyasint,omitzero"`
	NetworkRecv    float64             `json:"nr,omitzero" cbor:"17,keyasint,omitzero"`
	MaxNetworkSent float64             `json:"nsm,omitzero" cbor:"-"`
	MaxNetworkRecv float64             `json:"nrm,omitzero" cbor:"-"`
	Temperatures   map[string]float64  `json:"t,omitempty" cbor:"20,keyasint,omitempty"`
	ExtraFs        map[string]*FsStats `json:"efs,omitempty" cbor:"21,keyasint,omitempty"`
	GPUData        map[string]GPUData  `json:"g,omitempty" cbor:"22,keyasint,omitempty"`
	// cbor keys 23-25 were LoadAvg1/5/15 (removed) - do not reuse
	Bandwidth         [2]uint64            `json:"b,omitzero" cbor:"26,keyasint,omitzero"` // [sent bytes, recv bytes]
	MaxBandwidth      [2]uint64            `json:"bm,omitzero" cbor:"-"`                   // [sent bytes, recv bytes]
	LoadAvg           [3]float64           `json:"la,omitempty" cbor:"28,keyasint"`
	Battery           Battery              `json:"bat,omitzero" cbor:"29,keyasint,omitzero"`    // [percent, charge state]
	NetworkInterfaces map[string][4]uint64 `json:"ni,omitempty" cbor:"31,keyasint,omitempty"`   // [upload bytes, download bytes, total upload, total download]
	DiskIO            [2]uint64            `json:"dio,omitzero" cbor:"32,keyasint,omitzero"`    // [read bytes, write bytes]
	MaxDiskIO         [2]uint64            `json:"diom,omitzero" cbor:"-"`                      // [max read bytes, max write bytes]
	CpuBreakdown      []float64            `json:"cpub,omitempty" cbor:"33,keyasint,omitempty"` // [user, system, iowait, steal, idle, irq, softirq, nice]
	CpuCoresUsage     Uint8Slice           `json:"cpus,omitempty" cbor:"34,keyasint,omitempty"` // per-core busy usage [CPU0..]
	DiskIoStats       [6]float64           `json:"dios,omitzero" cbor:"35,keyasint,omitzero"`   // [read time %, write time %, io utilization %, r_await ms, w_await ms, weighted io %]
	MaxDiskIoStats    [6]float64           `json:"diosm,omitzero" cbor:"-"`                     // max values for DiskIoStats
	Fans              map[string]uint16    `json:"f,omitempty" cbor:"36,keyasint,omitempty"`
	Batteries         map[string]uint8     `json:"bats,omitempty" cbor:"37,keyasint,omitempty"`
	ZfsPools          map[string]*ZfsPool  `json:"z,omitempty" cbor:"39,keyasint,omitempty"`  // ZFS pool metrics, keyed by pool name
	DiskIOTotal       [2]uint64            `json:"diot,omitzero" cbor:"38,keyasint,omitzero"` // [total read bytes, total write bytes] cumulative device counters
	WiFi              map[string]int8      `json:"wf,omitempty" cbor:"40,keyasint,omitempty"` // RSSI dBm keyed by interface; unavailable readings omitted
	MemBytes          [4]uint64            `json:"mem,omitzero" cbor:"41,keyasint,omitzero"`  // [total, used, buff/cache, zfs arc] bytes
	MaxMemBytes       uint64               `json:"memm,omitzero" cbor:"-"`                    // max used memory bytes
	SwapBytes         [2]uint64            `json:"swap,omitzero" cbor:"42,keyasint,omitzero"` // [total, used] bytes
}

type Uint8Slice added in v0.15.3

type Uint8Slice []uint8

Uint8Slice wraps []uint8 to customize JSON encoding while keeping CBOR efficient. JSON: encodes as array of numbers (avoids base64 string). CBOR: falls back to default handling for []uint8 (byte string), keeping payload small.

func (Uint8Slice) MarshalJSON added in v0.15.3

func (s Uint8Slice) MarshalJSON() ([]byte, error)

type WiFi added in v0.21.0

type WiFi struct {
	SSID   string   `json:"s,omitempty" cbor:"0,keyasint,omitempty"`
	Signal *float64 `json:"r,omitempty" cbor:"1,keyasint,omitempty"`
}

WiFi describes a currently connected station interface. Keys in WiFi maps are OS interface identities, not SSIDs. Signal is native dBm only; nil means the OS confirmed association but could not supply RSSI (never convert quality %).

type ZfsPool added in v0.19.0

type ZfsPool struct {
	DisplayName string  `json:"n,omitempty" cbor:"8,keyasint,omitempty"`
	HideUsage   bool    `json:"hu,omitzero" cbor:"6,keyasint,omitempty"` // equivalent filesystem usage chart exists
	HideIO      bool    `json:"hi,omitzero" cbor:"7,keyasint,omitempty"` // equivalent filesystem I/O chart exists
	Raw         bool    `json:"raw,omitzero" cbor:"5,keyasint,omitempty"`
	Total       float64 `json:"d" cbor:"0,keyasint"`                     // total capacity in GiB
	Used        float64 `json:"du" cbor:"1,keyasint"`                    // allocated in GiB
	ReadBytes   uint64  `json:"rb,omitzero" cbor:"2,keyasint,omitzero"`  // read throughput in bytes/s
	WriteBytes  uint64  `json:"wb,omitzero" cbor:"3,keyasint,omitzero"`  // write throughput in bytes/s
	Health      string  `json:"h,omitempty" cbor:"4,keyasint,omitempty"` // ONLINE, DEGRADED, FAULTED, ...
}

ZfsPool holds per-pool ZFS metrics for a single collection interval.

Jump to

Keyboard shortcuts

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