hostutil

package
v1.9.3 Latest Latest
Warning

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

Go to latest
Published: Jan 24, 2022 License: MPL-2.0 Imports: 8 Imported by: 3

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type HostInfo

type HostInfo struct {
	// Timestamp returns the timestamp in UTC on the collection time.
	Timestamp time.Time `json:"timestamp"`
	// CPU returns information about the CPU such as family, model, cores, etc.
	CPU []cpu.InfoStat `json:"cpu"`
	// CPUTimes returns statistics on CPU usage represented in Jiffies.
	CPUTimes []cpu.TimesStat `json:"cpu_times"`
	// Disk returns statitics on disk usage for all accessible partitions.
	Disk []*disk.UsageStat `json:"disk"`
	// Host returns general host information such as hostname, platform, uptime,
	// kernel version, etc.
	Host *host.InfoStat `json:"host"`
	// Memory contains statistics about the memory such as total, available, and
	// used memory in number of bytes.
	Memory *mem.VirtualMemoryStat `json:"memory"`
}

HostInfo holds all the information that gets captured on the host. The set of information captured depends on the host operating system. For more information, refer to: https://github.com/shirou/gopsutil#current-status

func CollectHostInfo

func CollectHostInfo(ctx context.Context) (*HostInfo, error)

CollectHostInfo returns information on the host, which includes general host status, CPU, memory, and disk utilization.

The function does a best-effort capture on the most information possible, continuing on capture errors encountered and appending them to a resulting multierror.Error that gets returned at the end.

type HostInfoError

type HostInfoError struct {
	Type string
	Err  error
}

HostInfoError is a typed error for more convenient error checking.

func (*HostInfoError) Error

func (e *HostInfoError) Error() string

func (*HostInfoError) WrappedErrors

func (e *HostInfoError) WrappedErrors() []error

type VirtualMemoryStat added in v1.8.0

type VirtualMemoryStat struct {
	// Total amount of RAM on this system
	Total uint64

	// RAM available for programs to allocate
	//
	// This value is computed from the kernel specific values.
	Available uint64

	// RAM used by programs
	//
	// This value is computed from the kernel specific values.
	Used uint64

	// Percentage of RAM used by programs
	//
	// This value is computed from the kernel specific values.
	UsedPercent float64
}

VirutalMemoryStat holds commonly used memory measurements. We must have a local type here in order to avoid building the gopsutil library on certain arch types.

func CollectHostMemory added in v1.8.0

func CollectHostMemory(ctx context.Context) (*VirtualMemoryStat, error)

Jump to

Keyboard shortcuts

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