Documentation ¶
Index ¶
- Constants
- Variables
- func DbgErrCommon(method string, err error)
- func DbgInfCPU(method string, lastused, used, lasttotal, total uint64, percents float64)
- func DbgInfRAM(method string, used, total uint64, percents float64)
- func Debug(format string, arg ...interface{})
- type ReadSeekCloser
- type ResourceConfiger
- type ResourceStopper
- type ResourceType
- type ResourceViewer
- type Resourcer
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 ( CGroup1Files = []string{ CGroupCPULimitPath, CGroupMemLimitPath, CGroupCPUUsagePath, CGroupMemUsagePath, } CGroup2Files = []string{ CGroup2CPULimitPath, CGroup2MemLimitPath, CGroup2CPUUsagePath, CGroup2MemUsagePath, RAMFilenameInfoProc, } OSLinuxFiles = []string{ CPUfilenameInfoProc, RAMFilenameInfoProc, } )
View Source
var ErrNoResourcer = errors.New("no valid resourcer")
Functions ¶
func DbgErrCommon ¶ added in v0.1.3
Types ¶
type ReadSeekCloser ¶ added in v0.1.6
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 }
Click to show internal directories.
Click to hide internal directories.