hostinfo

package
v0.13.7 Latest Latest
Warning

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

Go to latest
Published: Jun 22, 2026 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Overview

Package hostinfo gathers a one-shot snapshot of the static facts of the machine a component runs on (OS, CPU, memory, NICs incl. both IPv4 and IPv6 addresses, and the kernel knobs that gate multicast throughput) for emission as a single host.inventory log event at startup.

It is best-effort: any field that cannot be read on the current platform is omitted rather than failing. Gather is called once per process lifetime, so it is not performance-sensitive and never touches a data-plane hot path.

Portability: portable facts come from gopsutil (pure Go, Linux + FreeBSD); interface addresses come from the standard library net package (both address families); deep NIC facts (link speed, driver, oper state) and sysctls are read from Linux sysfs/procfs and degrade to empty elsewhere.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Interface

type Interface struct {
	Name      string
	MAC       string
	MTU       int
	OperState string
	SpeedMbps int
	Duplex    string
	Driver    string
	IPv4      []string
	IPv6      []string
}

Interface describes one network interface. SpeedMbps, Duplex, Driver and OperState are populated only where the platform exposes them (Linux sysfs).

type Inventory

type Inventory struct {
	Hostname       string
	BootTime       uint64
	Uptime         uint64
	Virtualization string

	OS              string
	Platform        string
	PlatformVersion string
	KernelVersion   string

	CPUModel    string
	CPUPhysical int
	CPULogical  int
	CPUMHz      float64

	MemTotalBytes uint64

	Interfaces []Interface
	Sysctl     map[string]string

	Service     string
	Version     string
	GoVersion   string
	VCSRevision string
}

Inventory is the full host snapshot.

func Gather

func Gather(service, version string) Inventory

Gather collects the inventory. service and version identify the build.

func (Inventory) LogValue

func (inv Inventory) LogValue() slog.Value

LogValue implements slog.LogValuer so an Inventory logs as nested groups.

Jump to

Keyboard shortcuts

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