host

package
v0.0.0-...-38f4d7b Latest Latest
Warning

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

Go to latest
Published: Mar 25, 2023 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Overview

The host package is responsible for gathering details about a given host.

Index

Constants

View Source
const (
	DefaultMachineIDPath = "/etc/machine-id"
	DefaultProcRoot      = "/proc"
	OSReleaseFilePath    = "/etc/os-release"
	OSKernelFilePath     = "sys/kernel/osrelease"
	CPUInfoFilePath      = "cpuinfo"
	UnknownKey           = "UNKNOWN"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type CPUInfo

type CPUInfo struct {
	CPUCount int
}

CPUInfo represents details about the central processing unit.

type Hardware

type Hardware struct {
	CPU          CPUInfo
	Architecture string
}

Hardware represents the hardware on the machine.

type HostReader

type HostReader interface {
	// GetOS retrieves operating-system details
	GetOS() (*OS, error)
	// GetKernel retrieves kernel details.
	GetKernel() (*Kernel, error)
	// GetHardware retrieves hardware-level details. Or, in the case of a virtual machine, what is
	// exposed to the guest.
	GetHardware() (*Hardware, error)
	// GetHostID retrieves a unique identifier that represents the host (physical/virtual machine).
	GetHostID() (string, error)
}

HostReader defines the actions available for retrieving information about a host.

type Kernel

type Kernel struct {
	Type    string
	Version string
}

Kernel represents the operating-system's kernel's details.

type LinuxReader

type LinuxReader struct {
	// contains filtered or unexported fields
}

LinuxReader is the Linux-specific implementation of HostReader.

func NewLinuxReader

func NewLinuxReader(conf LinuxReaderConfig) LinuxReader

func (*LinuxReader) GetHardware

func (h *LinuxReader) GetHardware() (*Hardware, error)

func (*LinuxReader) GetHostID

func (h *LinuxReader) GetHostID() (string, error)

GetHostID provides a unique identifier representing the host. Today, it relies on [machine-id], which is created by Linux during installation. This functionality can be expanded over time to add methods for detecting the ID, when /etc/machine-id isn't possible or inadequate. If a ID is unable to be resolved, an error is returned.

func (*LinuxReader) GetKernel

func (h *LinuxReader) GetKernel() (*Kernel, error)

GetKernel retrieves details about the kernel of the operating system.

func (*LinuxReader) GetOS

func (h *LinuxReader) GetOS() (*OS, error)

GetOS looks up details about the operating system within /etc/os-release. We rely on details found inside os-release that comply with metadata found in the freedesktop specification.

type LinuxReaderConfig

type LinuxReaderConfig struct {
	ProcDirPath   string
	MachineIDPath string
}

type OS

type OS struct {
	Name    string
	Version string
}

OS represents details about the operating system.

Jump to

Keyboard shortcuts

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