common

package
v0.1.6 Latest Latest
Warning

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

Go to latest
Published: Jun 2, 2021 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

View Source
const (
	RAMFilenameInfoProc = "/proc/meminfo"
	CPUfilenameInfoProc = "/proc/stat"

	// https://www.kernel.org/doc/html/latest/admin-guide/cgroup-v2.html
	CGroup2MemUsagePath = "/sys/fs/cgroup/memory.current"
	CGroup2MemLimitPath = "/sys/fs/cgroup/memory.max"

	CGroup2CPUUsagePath = "/sys/fs/cgroup/cpu.stat"
	CGroup2CPULimitPath = "/sys/fs/cgroup/cpu.max"

	CGroupMemLimitPath = "/sys/fs/cgroup/memory/memory.limit_in_bytes"
	CGroupMemUsagePath = "/sys/fs/cgroup/memory/memory.usage_in_bytes"

	CGroupCPULimitPath = "/sys/fs/cgroup/cpu/cpu.cfs_quota_us"
	CGroupCPUUsagePath = "/sys/fs/cgroup/cpu/cpuacct.usage"

	CPUSleep = time.Second

	DefaultDuration = 3 * time.Second

	FailValue = -1.0
	DoneValue = -2.0
)
View Source
const (
	FmtErr     = "[%s]<ERR> check resource fails with %v"
	FmtCPUInfo = "[%s]<INFO> prev: %d/%d now: %d/%d (%.2f%%)"
	FmtRAMInfo = "[%s]<INFO> now: %d/%d (%.2f%%)"
)

Variables

View Source
var (
	ErrAllIsZero          = errors.New("total is zero")
	ErrTickPeriodZero     = errors.New("check period is zero")
	ErrNoResourceConfig   = errors.New("no resource config")
	ErrNoResourceReadFile = errors.New("file for check resource info not found")
)
View Source
var (
	IsDebug  = false
	Debugger = golog.New(log.New(os.Stdout, "ovsinc/resources-rate-limits", log.LstdFlags))
)
View Source
var ErrNoResourcer = errors.New("no valid resourcer")

Functions

func DbgErrCommon added in v0.1.3

func DbgErrCommon(method string, err error)

func DbgInfCPU added in v0.1.3

func DbgInfCPU(method string, lastused, used, lasttotal, total uint64, percents float64)

func DbgInfRAM added in v0.1.3

func DbgInfRAM(method string, used, total uint64, percents float64)

func Debug added in v0.1.2

func Debug(format string, arg ...interface{})

Types

type ReadSeekCloser added in v0.1.6

type ReadSeekCloser interface {
	io.Reader
	io.Seeker
	io.Closer
}

type ResourceConfiger added in v0.1.1

type ResourceConfiger interface {
	Type() ResourceType
	File(string) ReadSeekCloser
	Init() error
	Stop()
}

func NewResourceConfig added in v0.1.1

func NewResourceConfig(rtype ResourceType, fnames ...string) ResourceConfiger

type ResourceStopper added in v0.1.1

type ResourceStopper interface {
	Stop()
}

type ResourceType added in v0.1.1

type ResourceType uint16
const (
	ResourceType_UNKNOWN ResourceType = iota

	ResourceType_CG1
	ResourceType_CG2
	ResourceType_OS

	ResourceType_ENDS
)

type ResourceViewer

type ResourceViewer interface {
	Used() float64
}

type Resourcer

type Resourcer interface {
	ResourceStopper
	ResourceViewer
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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