Documentation
¶
Overview ¶
Package host provides the host information.
Index ¶
- Variables
- func Arch() string
- func BootID() string
- func BootTimeUnixSeconds() uint64
- func CPUFamily() string
- func CPULogicalCores() int
- func CPUModel() string
- func CPUModelName() string
- func CPUVendorID() string
- func DmidecodeUUID() string
- func GetBootID() (string, error)
- func GetDmidecodeUUID(ctx context.Context) (string, error)
- func GetMachineID(ctx context.Context) (string, error)
- func GetOSMachineID() (string, error)
- func GetOSName() (string, error)
- func GetSystemManufacturer(ctx context.Context) (string, error)
- func GetSystemUUID() (string, error)
- func HostID() string
- func KernelVersion() string
- func LastReboot(ctx context.Context) (time.Time, error)
- func LastRebootHelper(lines [][]byte) (time.Time, error)
- func MachineID() string
- func OSMachineID() string
- func OSName() string
- func Platform() string
- func PlatformFamily() string
- func PlatformVersion() string
- func Reboot(ctx context.Context, opts ...OpOption) error
- func Stop(ctx context.Context, opts ...OpOption) error
- func SystemManufacturer() string
- func SystemUUID() string
- type Op
- type OpOption
- type RebootEventStore
- type VirtualizationEnvironment
Constants ¶
This section is empty.
Variables ¶
var ErrNotRoot = errors.New("must be run as sudo/root")
Functions ¶
func BootTimeUnixSeconds ¶ added in v0.5.0
func BootTimeUnixSeconds() uint64
func CPULogicalCores ¶ added in v0.5.0
func CPULogicalCores() int
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 GetDmidecodeUUID ¶ added in v0.5.0
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
Returns the UUID of the machine host. Returns an empty string if the UUID is not found.
func GetOSMachineID ¶ added in v0.3.5
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 GetSystemManufacturer ¶ added in v0.5.0
GetSystemManufacturer detects the system manufacturer, using "dmidecode".
func GetSystemUUID ¶ added in v0.5.0
GetSystemUUID returns the system UUID of the machine. ref. https://github.com/google/cadvisor/blob/master/utils/sysfs/sysfs.go#L442
func KernelVersion ¶ added in v0.5.0
func KernelVersion() string
func LastRebootHelper ¶ added in v0.5.0
LastRebootHelper parses the last reboot time from the output of "uptime -s".
func OSMachineID ¶ added in v0.5.0
func OSMachineID() string
func PlatformFamily ¶ added in v0.5.0
func PlatformFamily() string
func PlatformVersion ¶ added in v0.5.0
func PlatformVersion() string
func SystemManufacturer ¶ added in v0.3.5
func SystemManufacturer() string
func SystemUUID ¶ added in v0.5.0
func SystemUUID() string
Types ¶
type OpOption ¶ added in v0.5.0
type OpOption func(*Op)
func WithDelaySeconds ¶ added in v0.5.0
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
Set true to run "systemctl reboot".
type RebootEventStore ¶ added in v0.5.0
type RebootEventStore interface {
RecordReboot(ctx context.Context) error
GetRebootEvents(ctx context.Context, since time.Time) (eventstore.Events, error)
}
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