inventory

package
v0.0.8 Latest Latest
Warning

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

Go to latest
Published: Mar 30, 2026 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Overview

Package inventory collects hardware inventory from sysfs and procfs.

Index

Constants

This section is empty.

Variables

View Source
var (
	ProcCPUInfoPath  = "/proc/cpuinfo"
	ProcMemInfoPath  = "/proc/meminfo"
	SysBlockPath     = "/sys/block"
	SysNetPath       = "/sys/class/net"
	SysDMIPath       = "/sys/class/dmi/id"
	SysPCIPath       = "/sys/bus/pci/devices"
	SysDMIMemoryPath = "/sys/firmware/dmi/entries/17-0"
	SysThermalPath   = "/sys/class/thermal"
	SysHwmonPath     = "/sys/class/hwmon"
	SysUSBPath       = "/sys/bus/usb/devices"
)

Paths can be overridden in tests.

Functions

func ClassifyUSBDevice added in v0.0.2

func ClassifyUSBDevice(classCode string) string

ClassifyUSBDevice returns a human-readable class name.

Types

type Accelerator

type Accelerator struct {
	Name    string `json:"name"`
	Vendor  string `json:"vendor"`
	PCIAddr string `json:"pciAddr"`
	Driver  string `json:"driver,omitempty"`
}

Accelerator describes a GPU or other accelerator card.

type CPUInfo

type CPUInfo struct {
	Model     string `json:"model"`
	Cores     int    `json:"cores"`
	Threads   int    `json:"threads"`
	Socket    int    `json:"socket"`
	FreqMHz   int    `json:"freqMHz"`
	Microcode string `json:"microcode"`
}

CPUInfo describes a single CPU socket.

type ChassisInfo added in v0.0.2

type ChassisInfo struct {
	Manufacturer string `json:"manufacturer"`
	Type         string `json:"type"`
	SerialNumber string `json:"serialNumber"`
	AssetTag     string `json:"assetTag"`
	Height       int    `json:"height"`
}

ChassisInfo captures physical enclosure information.

type DIMMInfo

type DIMMInfo struct {
	Slot     string `json:"slot"`
	SizeGB   int    `json:"sizeGB"`
	Type     string `json:"type"`
	SpeedMHz int    `json:"speedMHz"`
	ECC      bool   `json:"ecc"`
}

DIMMInfo describes one memory DIMM slot.

type DiskInfo

type DiskInfo struct {
	Name       string `json:"name"`
	Model      string `json:"model"`
	Serial     string `json:"serial"`
	SizeBytes  uint64 `json:"sizeBytes"`
	Type       string `json:"type"`
	Transport  string `json:"transport"`
	Firmware   string `json:"firmware"`
	Rotational bool   `json:"rotational"`
}

DiskInfo describes a block device.

type ExtendedInventory added in v0.0.2

type ExtendedInventory struct {
	Base               HardwareInventory `json:"base"`
	GPUs               []GPUInfo         `json:"gpus,omitempty"`
	StorageControllers []StorageCtrlInfo `json:"storageControllers,omitempty"`
	Thermal            *ThermalInfo      `json:"thermal,omitempty"`
	PowerSupplies      []PSUInfo         `json:"powerSupplies,omitempty"`
	USBDevices         []USBDeviceInfo   `json:"usbDevices,omitempty"`
	PCITopology        []PCIBridgeInfo   `json:"pciTopology,omitempty"`
	Transceivers       []TransceiverInfo `json:"transceivers,omitempty"`
	Chassis            *ChassisInfo      `json:"chassis,omitempty"`
}

ExtendedInventory adds operational data to the base HardwareInventory.

type FanInfo added in v0.0.2

type FanInfo struct {
	Name   string `json:"name"`
	RPM    int    `json:"rpm"`
	Status string `json:"status"`
}

FanInfo captures fan status.

type GPUInfo added in v0.0.2

type GPUInfo struct {
	Name          string `json:"name"`
	Vendor        string `json:"vendor"`
	PCIAddr       string `json:"pciAddr"`
	VRAM          uint64 `json:"vram"`
	Driver        string `json:"driver"`
	DriverVersion string `json:"driverVersion"`
	Architecture  string `json:"architecture"`
	NUMANode      int    `json:"numaNode"`
	SRIOVCapable  bool   `json:"sriovCapable"`
}

GPUInfo captures GPU/accelerator details.

func ScanGPUs added in v0.0.2

func ScanGPUs() []GPUInfo

ScanGPUs enumerates GPU/accelerator devices from sysfs.

type HardwareInventory

type HardwareInventory struct {
	Timestamp    time.Time     `json:"timestamp"`
	System       SystemInfo    `json:"system"`
	CPUs         []CPUInfo     `json:"cpus"`
	Memory       MemoryInfo    `json:"memory"`
	Disks        []DiskInfo    `json:"disks"`
	NICs         []NICInfo     `json:"nics"`
	PCIDevices   []PCIDevice   `json:"pciDevices,omitempty"`
	Accelerators []Accelerator `json:"accelerators,omitempty"`
}

HardwareInventory is the full hardware report collected during provisioning.

func Collect

func Collect() (*HardwareInventory, error)

Collect gathers a full hardware inventory from sysfs and procfs.

type MemoryInfo

type MemoryInfo struct {
	TotalBytes uint64     `json:"totalBytes"`
	DIMMs      []DIMMInfo `json:"dimms,omitempty"`
}

MemoryInfo holds total memory and optional DIMM details.

type NICInfo

type NICInfo struct {
	Name     string `json:"name"`
	Driver   string `json:"driver"`
	MAC      string `json:"mac"`
	PCIAddr  string `json:"pciAddr"`
	Speed    string `json:"speed"`
	SRIOVVFs int    `json:"sriovVfs"`
	Firmware string `json:"firmware"`
}

NICInfo describes a network interface.

type PCIBridgeInfo added in v0.0.2

type PCIBridgeInfo struct {
	Bus      string          `json:"bus"`
	NUMANode int             `json:"numaNode"`
	Children []PCIDeviceInfo `json:"children"`
}

PCIBridgeInfo captures PCI topology for NUMA affinity.

type PCIDevice

type PCIDevice struct {
	Address  string `json:"address"`
	Vendor   string `json:"vendor"`
	Device   string `json:"device"`
	Class    string `json:"class"`
	Driver   string `json:"driver,omitempty"`
	Revision string `json:"revision,omitempty"`
}

PCIDevice describes a PCI device from /sys/bus/pci/devices.

type PCIDeviceInfo added in v0.0.2

type PCIDeviceInfo struct {
	Addr     string `json:"addr"`
	Vendor   string `json:"vendor"`
	Device   string `json:"device"`
	Class    string `json:"class"`
	NUMANode int    `json:"numaNode"`
}

PCIDeviceInfo captures a PCI device in the topology.

type PSUInfo added in v0.0.2

type PSUInfo struct {
	Name   string `json:"name"`
	Status string `json:"status"`
	Watts  int    `json:"watts"`
	Model  string `json:"model"`
	Serial string `json:"serial"`
}

PSUInfo captures power supply details.

type SensorReading added in v0.0.2

type SensorReading struct {
	Name     string  `json:"name"`
	TempC    float64 `json:"tempC"`
	Warning  float64 `json:"warningC,omitempty"`
	Critical float64 `json:"criticalC,omitempty"`
}

SensorReading is a single temperature sensor reading.

type StorageCtrlInfo added in v0.0.2

type StorageCtrlInfo struct {
	Name       string `json:"name"`
	Vendor     string `json:"vendor"`
	Model      string `json:"model"`
	PCIAddr    string `json:"pciAddr"`
	FWVersion  string `json:"fwVersion"`
	Driver     string `json:"driver"`
	RAIDLevels string `json:"raidLevels"`
	Ports      int    `json:"ports"`
	CacheSize  uint64 `json:"cacheSize"`
	BBU        bool   `json:"bbu"`
}

StorageCtrlInfo captures RAID/HBA controller details.

type SystemInfo

type SystemInfo struct {
	Vendor       string `json:"vendor"`
	Product      string `json:"product"`
	SerialNumber string `json:"serialNumber"`
	UUID         string `json:"uuid"`
	BIOSVersion  string `json:"biosVersion"`
}

SystemInfo holds DMI system identification data.

type ThermalInfo added in v0.0.2

type ThermalInfo struct {
	CPUTemps    []SensorReading `json:"cpuTemps,omitempty"`
	InletTemp   *SensorReading  `json:"inletTemp,omitempty"`
	ExhaustTemp *SensorReading  `json:"exhaustTemp,omitempty"`
	Fans        []FanInfo       `json:"fans,omitempty"`
}

ThermalInfo captures temperature sensor data.

func CollectThermal added in v0.0.2

func CollectThermal() ThermalInfo

CollectThermal reads thermal sensor data from sysfs.

type TransceiverInfo added in v0.0.2

type TransceiverInfo struct {
	Interface  string  `json:"interface"`
	Type       string  `json:"type"`
	Vendor     string  `json:"vendor"`
	PartNumber string  `json:"partNumber"`
	Serial     string  `json:"serial"`
	TempC      float64 `json:"tempC"`
	PowerDBm   float64 `json:"powerDbm"`
}

TransceiverInfo captures SFP/QSFP module data.

type USBDeviceInfo added in v0.0.2

type USBDeviceInfo struct {
	Bus       int    `json:"bus"`
	Device    int    `json:"device"`
	VendorID  string `json:"vendorId"`
	ProductID string `json:"productId"`
	Name      string `json:"name"`
	Class     string `json:"class"`
}

USBDeviceInfo captures USB device details.

func ScanUSBDevices added in v0.0.2

func ScanUSBDevices() []USBDeviceInfo

ScanUSBDevices enumerates USB devices from sysfs.

Jump to

Keyboard shortcuts

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