Documentation
¶
Overview ¶
Package systeminfo is a generated GoMock package.
Index ¶
- Constants
- Variables
- func NewManager(log *log.PrefixLogger, exec executer.Executer, readWriter fileio.ReadWriter, ...) *manager
- type BIOSInfo
- type BlockInfo
- type Boot
- type CPUInfo
- type CollectCfg
- type CollectOpt
- type CollectorFn
- type DefaultRoute
- type DiskInfo
- type GPUDeviceInfo
- type GPUInfo
- type HardwareFacts
- type Info
- type InfoMap
- type InterfaceInfo
- type Manager
- type MemoryInfo
- type MockManager
- func (m *MockManager) BootID() string
- func (m *MockManager) BootTime() string
- func (m *MockManager) EXPECT() *MockManagerMockRecorder
- func (m *MockManager) IsRebooted() bool
- func (m *MockManager) RegisterCollector(ctx context.Context, name string, fn CollectorFn)
- func (m *MockManager) Status(arg0 context.Context, arg1 *v1alpha1.DeviceStatus, arg2 ...status.CollectorOpt) error
- type MockManagerMockRecorder
- func (mr *MockManagerMockRecorder) BootID() *gomock.Call
- func (mr *MockManagerMockRecorder) BootTime() *gomock.Call
- func (mr *MockManagerMockRecorder) IsRebooted() *gomock.Call
- func (mr *MockManagerMockRecorder) RegisterCollector(ctx, name, fn any) *gomock.Call
- func (mr *MockManagerMockRecorder) Status(arg0, arg1 any, arg2 ...any) *gomock.Call
- type MountInfo
- type NetworkInfo
- type PCIModelInfo
- type PCIVendorInfo
- type PartitionInfo
- type ProcessorInfo
- type SystemInfo
Constants ¶
const ( // PCI class codes for graphics devices VGACompatibleController = "0x030000" // VGA compatible controller DisplayController = "0x038000" // Other display controller ThreeDController = "0x030200" // 3D controller // Class code prefixes for graphics devices VGAPrefix = "0x0300" // Prefix for VGA compatible devices DisplayPrefix = "0x0380" // Prefix for other display controllers )
ref, https://admin.pci-ids.ucw.cz/read/PD
const ( // SystemFileName is the name of the file where the system boot status is stored in the data-dir. SystemFileName = "system.json" // HardwareMapFileName is the name of the file where the hardware map is stored. HardwareMapFileName = "hardware-map.yaml" )
Variables ¶
var SupportedInfoKeys = map[string]func(info *Info) string{ "hostname": func(i *Info) string { return i.Hostname }, "architecture": func(i *Info) string { return i.Architecture }, "kernel": func(i *Info) string { return i.Kernel }, "distroName": func(i *Info) string { if i.Distribution == nil { return "" } if val, ok := i.Distribution["name"]; ok { if s, ok := val.(string); ok { return s } return fmt.Sprint(val) } return "" }, "distroVersion": func(i *Info) string { if i.Distribution == nil { return "" } if val, ok := i.Distribution["version"]; ok { if str, ok := val.(string); ok { return str } return fmt.Sprint(val) } return "" }, "productName": func(i *Info) string { if i.Hardware.System != nil { return i.Hardware.System.ProductName } return "" }, "productSerial": func(i *Info) string { if i.Hardware.System != nil { return i.Hardware.System.SerialNumber } return "" }, "productUuid": func(i *Info) string { if i.Hardware.System != nil { return i.Hardware.System.UUID } return "" }, "biosVendor": func(i *Info) string { if i.Hardware.BIOS != nil { return i.Hardware.BIOS.Vendor } return "" }, "biosVersion": func(i *Info) string { if i.Hardware.BIOS != nil { return i.Hardware.BIOS.Version } return "" }, "netInterfaceDefault": func(i *Info) string { if i.Hardware.Network != nil && i.Hardware.Network.DefaultRoute != nil { return i.Hardware.Network.DefaultRoute.Interface } return "" }, "netIpDefault": func(i *Info) string { if i.Hardware.Network == nil || i.Hardware.Network.DefaultRoute == nil { return "" } dr := i.Hardware.Network.DefaultRoute for _, iface := range i.Hardware.Network.Interfaces { if iface.Name == dr.Interface { if len(iface.IPAddresses) == 0 { return "" } for _, addr := range iface.IPAddresses { ip := net.ParseIP(strings.Split(addr, "/")[0]) if ip != nil && !ip.IsLinkLocalUnicast() { return addr } } return iface.IPAddresses[0] } } return "" }, "netMacDefault": func(i *Info) string { if i.Hardware.Network == nil || i.Hardware.Network.DefaultRoute == nil { return "" } dr := i.Hardware.Network.DefaultRoute for _, iface := range i.Hardware.Network.Interfaces { if iface.Name == dr.Interface { return iface.MACAddress } } return "" }, "gpu": func(i *Info) string { if len(i.Hardware.GPU) == 0 { return "" } var parts []string for idx, gpu := range i.Hardware.GPU { parts = append(parts, fmt.Sprintf("[%d] %s %s", idx, gpu.Vendor, gpu.Model)) } return strings.Join(parts, ".") }, "memoryTotalKb": func(i *Info) string { if i.Hardware.Memory == nil || i.Hardware.Memory.TotalKB <= 0 { return "" } return fmt.Sprintf("%d", i.Hardware.Memory.TotalKB) }, "cpuCores": func(i *Info) string { if i.Hardware.CPU != nil { return fmt.Sprintf("%d", i.Hardware.CPU.TotalCores) } return "" }, "cpuProcessors": func(i *Info) string { if i.Hardware.CPU != nil { return fmt.Sprintf("%d", len(i.Hardware.CPU.Processors)) } return "" }, "cpuModel": func(i *Info) string { if i.Hardware.CPU != nil && len(i.Hardware.CPU.Processors) > 0 { return i.Hardware.CPU.Processors[0].Model } return "" }, }
SupportedInfoKeys is a map of supported info keys to their corresponding functions.
Functions ¶
func NewManager ¶
Types ¶
type BIOSInfo ¶
type BIOSInfo struct {
Vendor string `json:"vendor"`
Version string `json:"version"`
Date string `json:"date,omitempty"`
}
BIOSInfo represents BIOS information
type BlockInfo ¶
type BlockInfo struct {
TotalSizeBytes uint64 `json:"totalSizeBytes"`
TotalSizeGB float64 `json:"totalSizeGb"`
Disks []DiskInfo `json:"disks"`
Mounts []MountInfo `json:"mounts,omitempty"`
}
BlockInfo represents block device information
type Boot ¶
type CPUInfo ¶
type CPUInfo struct {
TotalCores int `json:"total_cores"`
TotalThreads int `json:"total_threads"`
Architecture string `json:"architecture"`
Processors []ProcessorInfo `json:"processors"`
}
CPUInfo represents CPU information
type CollectCfg ¶ added in v0.7.0
type CollectCfg struct {
// contains filtered or unexported fields
}
type CollectOpt ¶ added in v0.7.0
type CollectOpt func(*CollectCfg)
func WithAllCustom ¶ added in v0.7.0
func WithAllCustom() CollectOpt
WithAllCustom sets the allCustom option to true enabling all custom scripts to be collected.
type CollectorFn ¶ added in v0.7.0
CollectorFn is a function that collects system information. Collectors are best effort and should log any errors.
type DefaultRoute ¶
type DefaultRoute struct {
Interface string `json:"interface"`
Gateway string `json:"gateway"`
Family string `json:"family"` // "ipv4" or "ipv6"
}
DefaultRoute represents the default network route for IPv4 or IPv6.
type DiskInfo ¶
type DiskInfo struct {
Name string `json:"name"`
SizeBytes uint64 `json:"sizeBytes"`
SizeGB float64 `json:"sizeGb"`
DriveType string `json:"driveType"`
StorageController string `json:"storageController"`
Vendor string `json:"vendor,omitempty"`
Model string `json:"model,omitempty"`
SerialNumber string `json:"serialNumber,omitempty"`
WWN string `json:"wwn,omitempty"`
BusType string `json:"busType,omitempty"`
Partitions []PartitionInfo `json:"partitions,omitempty"`
}
DiskInfo contains information about a single disk
type GPUDeviceInfo ¶
type GPUDeviceInfo struct {
Index int `json:"index"`
Vendor string `json:"vendor"`
Model string `json:"model"`
DeviceID string `json:"deviceId,omitempty"`
PCIAddress string `json:"pciAddress,omitempty"`
RevisionID string `json:"revisionId,omitempty"`
VendorID string `json:"vendorId,omitempty"`
MemoryBytes uint64 `json:"memoryBytes,omitempty"`
Arch string `json:"architecture,omitempty"`
Features []string `json:"features,omitempty"`
}
GPUDeviceInfo contains information about a GPU device
type GPUInfo ¶
type GPUInfo struct {
GPUs []GPUDeviceInfo `json:"gpus"`
}
GPUInfo represents GPU information
type HardwareFacts ¶
type HardwareFacts struct {
CPU *CPUInfo `json:"cpu,omitempty"`
Memory *MemoryInfo `json:"memory,omitempty"`
Block *BlockInfo `json:"block,omitempty"`
Network *NetworkInfo `json:"network,omitempty"`
GPU []GPUDeviceInfo `json:"gpu,omitempty"`
BIOS *BIOSInfo `json:"bios,omitempty"`
System *SystemInfo `json:"system,omitempty"`
}
HardwareFacts contains hardware information gathered by ghw
type Info ¶
type Info struct {
Hostname string `json:"hostname"`
Architecture string `json:"architecture"`
OperatingSystem string `json:"operatingSystem"`
Kernel string `json:"kernel"`
Distribution map[string]interface{} `json:"distribution,omitempty"`
Hardware HardwareFacts `json:"hardware"`
CollectedAt string `json:"collectedAt"`
Metadata map[string]interface{} `json:"metadata,omitempty"`
Boot Boot `json:"boot,omitempty"`
Custom map[string]string `json:"custom,omitempty"`
}
type InterfaceInfo ¶
type InterfaceInfo struct {
Name string `json:"name"`
MACAddress string `json:"macAddress"`
IsVirtual bool `json:"isVirtual"`
IPAddresses []string `json:"ipAddresses,omitempty"`
MTU int `json:"mtu,omitempty"`
Status string `json:"status,omitempty"`
}
InterfaceInfo contains information about a network interface
type Manager ¶
type Manager interface {
// IsRebooted checks if the system has been rebooted since the last time the agent started
IsRebooted() bool
// BootID returns the unique boot ID populated by the kernel
BootID() string
// BootTime returns the time the system was booted
BootTime() string
// RegisterCollector registers a system info collector
RegisterCollector(ctx context.Context, name string, fn CollectorFn)
status.Exporter
}
type MemoryInfo ¶
type MemoryInfo struct {
TotalKB uint64 `json:"totalKb"`
Details map[string]interface{} `json:"details,omitempty"`
}
MemoryInfo represents memory information
type MockManager ¶
type MockManager struct {
// contains filtered or unexported fields
}
MockManager is a mock of Manager interface.
func NewMockManager ¶
func NewMockManager(ctrl *gomock.Controller) *MockManager
NewMockManager creates a new mock instance.
func (*MockManager) EXPECT ¶
func (m *MockManager) EXPECT() *MockManagerMockRecorder
EXPECT returns an object that allows the caller to indicate expected use.
func (*MockManager) IsRebooted ¶
func (m *MockManager) IsRebooted() bool
IsRebooted mocks base method.
func (*MockManager) RegisterCollector ¶ added in v0.7.0
func (m *MockManager) RegisterCollector(ctx context.Context, name string, fn CollectorFn)
RegisterCollector mocks base method.
func (*MockManager) Status ¶
func (m *MockManager) Status(arg0 context.Context, arg1 *v1alpha1.DeviceStatus, arg2 ...status.CollectorOpt) error
Status mocks base method.
type MockManagerMockRecorder ¶
type MockManagerMockRecorder struct {
// contains filtered or unexported fields
}
MockManagerMockRecorder is the mock recorder for MockManager.
func (*MockManagerMockRecorder) BootID ¶
func (mr *MockManagerMockRecorder) BootID() *gomock.Call
BootID indicates an expected call of BootID.
func (*MockManagerMockRecorder) BootTime ¶
func (mr *MockManagerMockRecorder) BootTime() *gomock.Call
BootTime indicates an expected call of BootTime.
func (*MockManagerMockRecorder) IsRebooted ¶
func (mr *MockManagerMockRecorder) IsRebooted() *gomock.Call
IsRebooted indicates an expected call of IsRebooted.
func (*MockManagerMockRecorder) RegisterCollector ¶ added in v0.7.0
func (mr *MockManagerMockRecorder) RegisterCollector(ctx, name, fn any) *gomock.Call
RegisterCollector indicates an expected call of RegisterCollector.
type MountInfo ¶
type MountInfo struct {
Device string `json:"device"`
MountPoint string `json:"mountPoint"`
FSType string `json:"fsType"`
Options string `json:"options"`
}
MountInfo contains information about a filesystem mount
type NetworkInfo ¶
type NetworkInfo struct {
Interfaces []InterfaceInfo `json:"interfaces"`
DefaultRoute *DefaultRoute `json:"defaultRoute,omitempty"`
DNSServers []string `json:"dnsServers,omitempty"`
FQDN string `json:"fqdn,omitempty"`
}
NetworkInfo represents network information
type PCIModelInfo ¶
type PCIModelInfo struct {
PCIID string `json:"pciID"`
PCIName string `json:"pciName"`
MemoryBytes uint64 `json:"memoryBytes,omitempty"`
Arch string `json:"architecture,omitempty"`
Features []string `json:"features,omitempty"`
}
PCIModelInfo contains information about a specific GPU model
type PCIVendorInfo ¶
type PCIVendorInfo struct {
Models []PCIModelInfo `json:"models"`
VendorID string `json:"vendorID"`
VendorName string `json:"vendorName"`
}
PCIVendorInfo contains mapping information for vendors and models
type PartitionInfo ¶
type PartitionInfo struct {
Name string `json:"name"`
SizeBytes uint64 `json:"sizeBytes"`
SizeGB float64 `json:"sizeGb"`
MountPoint string `json:"mountPoint,omitempty"`
Type string `json:"type,omitempty"`
IsReadOnly bool `json:"isReadOnly,omitempty"`
}
PartitionInfo contains information about a disk partition
type ProcessorInfo ¶
type ProcessorInfo struct {
ID int `json:"id"`
NumCores int `json:"numCores"`
NumThreads int `json:"numThreads"`
NumThreadsPerCore int `json:"numThreadsPerCore"`
Vendor string `json:"vendor"`
Model string `json:"model"`
Capabilities []string `json:"capabilities,omitempty"`
}
ProcessorInfo contains information about a single processor
type SystemInfo ¶
type SystemInfo struct {
Manufacturer string `json:"manufacturer"`
ProductName string `json:"productName"`
SerialNumber string `json:"serialNumber,omitempty"`
UUID string `json:"uuid,omitempty"`
Version string `json:"version,omitempty"`
Family string `json:"family,omitempty"`
SKU string `json:"sku,omitempty"`
}
SystemInfo represents system information