host

package
v0.3.9 Latest Latest
Warning

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

Go to latest
Published: Jan 10, 2025 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Overview

Package host provides the host information.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DmidecodeUUID added in v0.3.5

func DmidecodeUUID(ctx context.Context) (string, error)

Fetches the UUIF of the machine host, using the "dmidecode". Returns an empty string if the UUID is not found.

ref. UUID=$(dmidecode -t 1 | grep -i UUID | awk '{print $2}')

func GetBootID added in v0.3.5

func GetBootID() (string, error)

Returns an empty string if the boot ID is not found.

func GetMachineID added in v0.3.5

func GetMachineID(ctx context.Context) (string, error)

Returns the UUID of the machine host. Returns an empty string if the UUID is not found.

func GetOSMachineID added in v0.3.5

func GetOSMachineID() (string, error)

Returns the OS-level UUID based on /etc/machine-id or /var/lib/dbus/machine-id. Returns an empty string if the UUID is not found.

func SystemManufacturer added in v0.3.5

func SystemManufacturer(ctx context.Context) (string, error)

SystemManufacturer detects the system manufacturer, using "dmidecode".

Types

type VirtualizationEnvironment added in v0.3.5

type VirtualizationEnvironment struct {
	// Type is the virtualization type.
	// Output of "systemd-detect-virt".
	// e.g., "kvm" for VM, "lxc" for container
	Type string `json:"type"`

	// Whether the host is running in a VM.
	// Output of "systemd-detect-virt --vm".
	// Set to "none" if the host is not running in a VM.
	// e.g., "kvm"
	VM string `json:"vm"`

	// Whether the host is running in a container.
	// Output of "systemd-detect-virt --container".
	// Set to "none" if the host is not running in a container.
	// e.g., "lxc"
	Container string `json:"container"`

	// Whether the host is running in a KVM.
	// Set to "false" if the host is not running in a KVM.
	IsKVM bool `json:"is_kvm"`
}

VirtualizationEnvironment represents the virtualization environment of the host.

func SystemdDetectVirt added in v0.3.5

func SystemdDetectVirt(ctx context.Context) (VirtualizationEnvironment, error)

SystemdDetectVirt detects the virtualization type of the host, using "systemd-detect-virt".

Jump to

Keyboard shortcuts

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