Documentation ¶
Overview ¶
Package system provides system utility functions initially required by `cbbackupmgr`.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Execute ¶
Execute will execute the given command in the platforms default shell/command prompt and return the combined stdout/stderr output.
NOTE: In the event of an error, the returned string will always be empty, the error message will contain all the valid information about why the command failed.
func NumCPU ¶
func NumCPU() int
NumCPU returns GOMAXPROCS (defaults to vCPUs) detected by the runtime multiplied by a constant. This function should be used when determining how many Goroutines to create for performing short running tasks which benefit from being performed concurrently. We currently multiply the value by 0.75 to avoid over-saturating the CPU in cases where multiple instances of cbbackupmgr can be run on a single machine e.g. when running info during a merge.
func NumWorkers ¶
NumWorkers returns a sane number of workers to create when performing a task concurrently. This function should be used for the same reason as 'NumCPU', however, with the added caveat that we'd like to ensure we don't create more workers than the amount of work that is going to be processed.
func RaiseFileLimit ¶
RaiseFileLimit will check if the ulimit on open files is bigger or equal to threshold if it is it will return. Otherwise it will try to raise it and return true. If it fails it will return false.
func TotalMemory ¶
TotalMemory returns the total physical memory available on the host machine in bytes.
NOTE: This function is a wrapper around os specific functions which ensures that we always return the same value and only calculate it once.
Types ¶
type Information ¶
type Information struct { Hostname string OS string Version string Arch string VCPU int Memory uint64 }
Information represents useful system information which is logged by 'cbbackupmgr' at the beginning of each command.
func GetInformation ¶
func GetInformation(logger *slog.Logger) Information
GetInformation fetches and returns common system information in a platform agnostic fashion.
NOTE: On supported platforms, the returned information may not be that of the host system but of any limits applied.
func (Information) String ¶
func (i Information) String() string
String implements the 'Stringer' interface note changes to this format should be considered carefully as to note break backwards compatibility.