Documentation ¶
Index ¶
- func GetCPUPeriodAndQuota() (period int64, quota int64, err error)
- func GetMemoryInactiveFileUsage() (usage uint64, err error)
- func GetMemoryLimit() (limit uint64, err error)
- func GetMemoryUsage() (usage uint64, err error)
- func InContainer() bool
- func SetGOMAXPROCS() (func(), error)
- type CPUQuotaStatus
- type CPUUsage
- type Version
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func GetCPUPeriodAndQuota ¶
GetCPUPeriodAndQuota returns CPU period and quota time of cgroup.
func GetMemoryInactiveFileUsage ¶
GetMemoryInactiveFileUsage attempts to retrieve the cgroup memory usage value (in bytes) for the current process.
func GetMemoryLimit ¶
GetMemoryLimit attempts to retrieve the cgroup memory limit for the current process.
func GetMemoryUsage ¶
GetMemoryUsage attempts to retrieve the cgroup memory usage value (in bytes) for the current process.
func InContainer ¶
func InContainer() bool
InContainer returns true if the process is running in a container.
func SetGOMAXPROCS ¶
func SetGOMAXPROCS() (func(), error)
SetGOMAXPROCS is to set GOMAXPROCS to the number of CPUs.
Types ¶
type CPUQuotaStatus ¶
type CPUQuotaStatus int
CPUQuotaStatus presents the status of how CPU quota is used
const ( // CPUQuotaUndefined is returned when CPU quota is undefined CPUQuotaUndefined CPUQuotaStatus = iota // CPUQuotaUsed is returned when a valid CPU quota can be used CPUQuotaUsed // CPUQuotaMinUsed is return when CPU quota is smaller than the min value CPUQuotaMinUsed )
func CPUQuotaToGOMAXPROCS ¶
func CPUQuotaToGOMAXPROCS(minValue int) (int, CPUQuotaStatus, error)
CPUQuotaToGOMAXPROCS converts the CPU quota applied to the calling process to a valid GOMAXPROCS value.
type CPUUsage ¶
type CPUUsage struct {
// System time and user time taken by this cgroup or process. In nanoseconds.
Stime, Utime uint64
// CPU period and quota for this process, in microseconds. This cgroup has
// access to up to (quota/period) proportion of CPU resources on the system.
// For instance, if there are 4 CPUs, quota = 150000, period = 100000,
// this cgroup can use around ~1.5 CPUs, or 37.5% of total scheduler time.
// If quota is -1, it's unlimited.
Period, Quota int64
// NumCPUs is the number of CPUs in the system. Always returned even if
// not called from a cgroup.
NumCPU int
}
CPUUsage returns CPU usage and quotas for an entire cgroup.
func GetCgroupCPU ¶
GetCgroupCPU returns the CPU usage and quota for the current cgroup.
type Version ¶
type Version int
Version represents the cgroup version.
func GetCgroupMemLimit ¶
GetCgroupMemLimit attempts to retrieve the cgroup memory limit for the current process, and return cgroup version too.