Movatterモバイル変換


[0]ホーム

URL:


Alert GO-2024-3228: Coder vulnerable to post-auth URL redirection to untrusted site ('Open Redirect') in github.com/coder/coder
Notice  The highest tagged major version isv2.

clistat

package
v0.27.3Latest Latest
Warning

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

Go to latest
Published: Aug 1, 2023 License:AGPL-3.0Imports:15Imported by:0

Details

Repository

github.com/coder/coder

Links

Documentation

Index

Constants

View Source
const (PrefixDefault = 1.0PrefixKibi    = 1024.0PrefixMebi    =PrefixKibi * 1024.0PrefixGibi    =PrefixMebi * 1024.0PrefixTebi    =PrefixGibi * 1024.0)

Variables

View Source
var (PrefixHumanKibi = "Ki"PrefixHumanMebi = "Mi"PrefixHumanGibi = "Gi"PrefixHumanTebi = "Ti")

Functions

funcIsContainerized

func IsContainerized(fsafero.Fs) (okbool, errerror)

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)

funcWithFS

func WithFS(fsafero.Fs)Option

WithFS sets the fs for the statter.

funcWithSampleInterval

func WithSampleInterval(dtime.Duration)Option

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

func ParsePrefix(sstring)Prefix

func (*Prefix)String

func (s *Prefix) String()string

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.

func (*Result)String

func (r *Result) String()string

String returns a human-readable representation of the result.

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.

funcNew

func New(opts ...Option) (*Statter,error)

func (*Statter)ContainerCPU

func (s *Statter) ContainerCPU() (*Result,error)

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

func (s *Statter) ContainerMemory(pPrefix) (*Result,error)

ContainerMemory returns the memory usage of the container cgroup.If the system is not containerized, this always returns nil.

func (*Statter)Disk

func (*Statter) Disk(pPrefix, pathstring) (*Result,error)

Disk returns the disk usage of the given path.If path is empty, it returns the usage of the root directory.

func (*Statter)HostCPU

func (s *Statter) HostCPU() (*Result,error)

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".

func (*Statter)HostMemory

func (s *Statter) HostMemory(pPrefix) (*Result,error)

HostMemory returns the memory usage of the host, in gigabytes.

Source Files

View all Source files

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f orF : Jump to
y orY : Canonical URL
go.dev uses cookies from Google to deliver and enhance the quality of its services and to analyze traffic.Learn more.

[8]ページ先頭

©2009-2025 Movatter.jp