host

package
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Nov 27, 2026 License: MIT Imports: 7 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package host reads the facts of the host, such as its hostname, its OS and its uptime.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Gohai added in v0.3.0

type Gohai struct {
	// Sources are what the collectors read. A zero field is the real
	// host's.
	Sources source.Sources
}

Gohai reads the host's name, OS and uptime with gohai's collectors, on every Linux family and on macOS.

func New added in v0.3.0

func New() *Gohai

New returns a provider that reads the real host.

func (*Gohai) GetHostname added in v0.3.0

func (g *Gohai) GetHostname() (string, error)

GetHostname is the host's name, as `hostname` prints it.

func (*Gohai) GetOSInfo added in v0.3.0

func (g *Gohai) GetOSInfo() (*Result, error)

GetOSInfo is the distribution and its version, as gohai's platform collector names them: ubuntu 24.04, darwin 15.4.

func (*Gohai) GetUptime added in v0.3.0

func (g *Gohai) GetUptime() (time.Duration, error)

GetUptime is the time since the host booted.

type Provider

type Provider interface {
	// GetUptime retrieves the system uptime.
	GetUptime() (time.Duration, error)
	// GetHostname retrieves the hostname of the system.
	GetHostname() (string, error)
	// GetOSInfo retrieves information about the operating system, including the
	// distribution name and version.
	GetOSInfo() (*Result, error)
}

Provider implements the methods to interact with various Host components.

type Result

type Result struct {
	// The name of the Linux distribution (e.g., Debian, CentOS).
	Distribution string
	// The version of the Linux distribution (e.g., 20.04, 8.3).
	Version string
	// Family is the platform family that the agent resolves providers by, as
	// gohai's family.Detect names it (e.g., debian, suse, darwin).
	Family string
	// Changed indicates whether system state was modified.
	Changed bool `json:"changed"`
}

Result represents the operating system information.

Directories

Path Synopsis
Package mocks provides mock implementations for testing.
Package mocks provides mock implementations for testing.

Jump to

Keyboard shortcuts

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