clistat
packageThis package is not in the latest version of its module.
Details
Validgo.mod file
The Go module system was introduced in Go 1.11 and is the official dependency management solution for Go.
Redistributable license
Redistributable licenses place minimal restrictions on how software can be used, modified, and redistributed.
Tagged version
Modules with tagged versions give importers more predictable builds.
Stable version
When a project reaches major version v1 it is considered stable.
- Learn more about best practices
Repository
Links
Documentation¶
Index¶
Constants¶
const (PrefixDefault = 1.0PrefixKibi = 1024.0PrefixMebi =PrefixKibi * 1024.0PrefixGibi =PrefixMebi * 1024.0PrefixTebi =PrefixGibi * 1024.0)
Variables¶
var (PrefixHumanKibi = "Ki"PrefixHumanMebi = "Mi"PrefixHumanGibi = "Gi"PrefixHumanTebi = "Ti")
Functions¶
funcIsContainerized¶
IsContainerized returns whether the host is containerized.This is adapted fromhttps://github.com/elastic/go-sysinfo/tree/main/providers/linux/container.go#L31with modifications to support Sysbox containers.On non-Linux platforms, it always returns false.
Types¶
typeOption¶
type Option func(*Statter)
funcWithSampleInterval¶
WithSampleInterval sets the sample interval for the statter.
typePrefix¶
type Prefixfloat64
Prefix is a scale multiplier for a result.Used when creating a human-readable representation.
funcParsePrefix¶
typeResult¶
type Result struct {Total *float64 `json:"total"`Unitstring `json:"unit"`Usedfloat64 `json:"used"`PrefixPrefix `json:"-"`}
Result is a generic result type for a statistic.Total is the total amount of the resource available.It is nil if the resource is not a finite quantity.Unit is the unit of the resource.Used is the amount of the resource used.
typeStatter¶
type Statter struct {// contains filtered or unexported fields}
Statter is a system statistics collector.It is a thin wrapper around the elastic/go-sysinfo library.
func (*Statter)ContainerCPU¶
ContainerCPU returns the CPU usage of the container cgroup.This is calculated as difference of two samples of theCPU usage of the container cgroup.The total is read from the relevant path in /sys/fs/cgroup.If there is no limit set, the total is assumed to be thenumber of host cores multiplied by the CFS period.If the system is not containerized, this always returns nil.
func (*Statter)ContainerMemory¶
ContainerMemory returns the memory usage of the container cgroup.If the system is not containerized, this always returns nil.
func (*Statter)Disk¶
Disk returns the disk usage of the given path.If path is empty, it returns the usage of the root directory.
func (*Statter)HostCPU¶
HostCPU returns the CPU usage of the host. This is calculated bytaking two samples of CPU usage and calculating the difference.Total will always be equal to the number of cores.Used will be an estimate of the number of cores used during the sample interval.This is calculated by taking the difference between the total and idle HostCPU timeand scaling it by the number of cores.Units are in "cores".