host

package
v0.9.0-alpha.13 Latest Latest
Warning

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

Go to latest
Published: Nov 20, 2025 License: Apache-2.0 Imports: 18 Imported by: 0

Documentation

Overview

Package host provides the host information.

Index

Constants

View Source
const (
	EventBucketName = "os"
	EventNameReboot = "reboot"
)

Variables

View Source
var ErrNotRoot = errors.New("must be run as sudo/root")

Functions

func Arch added in v0.5.0

func Arch() string

func BootID added in v0.5.0

func BootID() string

func BootTime added in v0.9.0

func BootTime() time.Time

BootTime returns the host boot time in UTC. A zero value indicates the boot time could not be determined during initialization.

func BootTimeUnixSeconds added in v0.5.0

func BootTimeUnixSeconds() uint64

func CPUFamily added in v0.5.0

func CPUFamily() string

func CPULogicalCores added in v0.5.0

func CPULogicalCores() int

func CPUModel added in v0.5.0

func CPUModel() string

func CPUModelName added in v0.5.0

func CPUModelName() string

func CPUVendorID added in v0.5.0

func CPUVendorID() string

func DmidecodeUUID added in v0.3.5

func DmidecodeUUID() string

func GetBootID added in v0.3.5

func GetBootID() (string, error)

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

func GetDmidecodeUUID added in v0.5.0

func GetDmidecodeUUID(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 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)

GetOSMachineID 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 GetOSName added in v0.5.0

func GetOSName() (string, error)

GetOSName reads the os name from the /etc/os-release file.

func GetSystemManufacturer added in v0.5.0

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

GetSystemManufacturer detects the system manufacturer, using "dmidecode".

func GetSystemUUID added in v0.5.0

func GetSystemUUID() (string, error)

GetSystemUUID returns the system UUID of the machine. ref. https://github.com/google/cadvisor/blob/master/utils/sysfs/sysfs.go#L442

func HostID added in v0.5.0

func HostID() string

func KernelVersion added in v0.5.0

func KernelVersion() string

func MachineID added in v0.5.0

func MachineID() string

func OSMachineID added in v0.5.0

func OSMachineID() string

func OSName added in v0.5.0

func OSName() string

func Platform added in v0.5.0

func Platform() string

func PlatformFamily added in v0.5.0

func PlatformFamily() string

func PlatformVersion added in v0.5.0

func PlatformVersion() string

func Reboot added in v0.5.0

func Reboot(ctx context.Context, opts ...OpOption) error

Reboot reboots the system.

func Stop added in v0.5.0

func Stop(ctx context.Context, opts ...OpOption) error

Stop stops the gpud service

func SystemManufacturer added in v0.3.5

func SystemManufacturer() string

func SystemUUID added in v0.5.0

func SystemUUID() string

Types

type Op added in v0.5.0

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

type OpOption added in v0.5.0

type OpOption func(*Op)

func WithDelaySeconds added in v0.5.0

func WithDelaySeconds(delaySeconds int) OpOption

Specifies the delay seconds before rebooting. Useful for the remote server to get the response from a GPUd daemon.

func WithSystemctl added in v0.5.0

func WithSystemctl(b bool) OpOption

Set true to run "systemctl reboot".

type RebootEventStore added in v0.5.0

type RebootEventStore interface {
	// RecordReboot records a reboot event, with the event name [EventNameReboot],
	// in the bucket [EventBucketName].
	RecordReboot(ctx context.Context) error

	// GetRebootEvents queries all "reboot" events and if any extra buckets are provided,
	// it will also query the events from the extra buckets, with the same since time.
	// The returned events do NOT include other events from the "os" component (e.g., kmsg watcher).
	// The returned events are in the descending order of timestamp (latest event first).
	GetRebootEvents(ctx context.Context, since time.Time) (eventstore.Events, error)
}

RebootEventStore is the interface for the reboot event store. It is used to record and query reboot events.

func NewRebootEventStore added in v0.5.0

func NewRebootEventStore(eventStore eventstore.Store) RebootEventStore

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 GetSystemdDetectVirt added in v0.5.0

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

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

func VirtualizationEnv added in v0.5.0

func VirtualizationEnv() VirtualizationEnvironment

Jump to

Keyboard shortcuts

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