cgroup

package
v0.4.2 Latest Latest
Warning

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

Go to latest
Published: Mar 14, 2023 License: Apache-2.0 Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	KubePodCGroupPath string = cGroupSlicePath(baseCGroupPath, kubepodSlice)
	SystemCGroupPath  string = cGroupSlicePath(baseCGroupPath, systemSlice)
)
View Source
var MemUsageFiles = []string{
	"memory.usage_in_bytes",
	"memory.kmem.usage_in_bytes",
	"memory.kmem.tcp.usage_in_bytes",
	"memory.current",
}

Functions

func AddContainerIDToCache

func AddContainerIDToCache(pid uint64, containerID string)

AddContainerIDToCache add the container id to cache using the pid as the key

func DefaultConverter

func DefaultConverter(stats map[string]interface{}, key string) interface{}

func GetAliveContainers

func GetAliveContainers() (map[string]bool, error)

GetAliveContainers returns alive pod map

func GetAvailableCgroupMetrics

func GetAvailableCgroupMetrics() []string

func GetAvailableKubeletMetrics

func GetAvailableKubeletMetrics() []string

func GetContainerID

func GetContainerID(cGroupID, pid uint64, withCGroupID bool) (string, error)

func GetContainerIDFromPID

func GetContainerIDFromPID(pid uint64) (string, error)

GetContainerIDFromPID find the container ID using the process PID

func GetContainerMetrics

func GetContainerMetrics() (containerCPU, containerMem map[string]float64, nodeCPU, nodeMem float64, retErr error)

func GetContainerName

func GetContainerName(cGroupID, pid uint64, withCGroupID bool) (string, error)

func GetPodName

func GetPodName(cGroupID, pid uint64, withCGroupID bool) (string, error)

func GetPodNameSpace

func GetPodNameSpace(cGroupID, pid uint64, withCGroupID bool) (string, error)

func GetStandardStat

func GetStandardStat(containerID string) map[string]interface{}

func HasCgroupExportMetric

func HasCgroupExportMetric(availableMetrics []string) bool

func Init

func Init() (*[]corev1.Pod, error)

func NanoToMicroConverter

func NanoToMicroConverter(stats map[string]interface{}, key string) interface{}

func ParseContainerIDFromPodStatus

func ParseContainerIDFromPodStatus(containerID string) string

func ReadAllCgroupIOStat

func ReadAllCgroupIOStat() (rBytes, wBytes uint64, disks int, err error)

func ReadCgroupIOStat

func ReadCgroupIOStat(cGroupID, pid uint64) (rBytes, wBytes uint64, disks int, err error)

func ReadKV

func ReadKV(fileName string) (map[string]interface{}, error)

func ReadLineKEqualToV

func ReadLineKEqualToV(fileName string) (map[string]interface{}, error)

func ReadUInt64

func ReadUInt64(fileName string) (uint64, error)

func SearchByContainerID

func SearchByContainerID(topFolder, containerID string) string

func SearchBySuffix

func SearchBySuffix(topFolder, suffix string) string

func SetSliceHandler

func SetSliceHandler()

func TryInitStatReaders

func TryInitStatReaders(containerID string)

Types

type CPUStatReader

type CPUStatReader struct {
	Path string
}

func (CPUStatReader) Read

func (s CPUStatReader) Read() map[string]interface{}

type CgroupFSReadMetric

type CgroupFSReadMetric struct {
	Name      string
	Converter func(stats map[string]interface{}, key string) interface{}
}

type ContainerInfo

type ContainerInfo struct {
	ContainerID   string
	ContainerName string
	PodName       string
	Namespace     string
}

type IOStatReader

type IOStatReader struct {
	Path string
}

func (IOStatReader) Read

func (s IOStatReader) Read() map[string]interface{}

type MemoryStatReader

type MemoryStatReader struct {
	Path string
}

func (MemoryStatReader) Read

func (s MemoryStatReader) Read() map[string]interface{}

type SliceHandler

type SliceHandler struct {
	CPUTopPath    string
	MemoryTopPath string
	IOTopPath     string
	// contains filtered or unexported fields
}
var SliceHandlerInstance *SliceHandler

func InitSliceHandler

func InitSliceHandler() *SliceHandler

func (*SliceHandler) GetCPUTopPath

func (s *SliceHandler) GetCPUTopPath() string

func (*SliceHandler) GetIOTopPath

func (s *SliceHandler) GetIOTopPath() string

func (*SliceHandler) GetMemoryTopPath

func (s *SliceHandler) GetMemoryTopPath() string

func (*SliceHandler) GetStatReaders

func (s *SliceHandler) GetStatReaders() map[string][]StatReader

func (*SliceHandler) GetStats

func (s *SliceHandler) GetStats(containerID string) map[string]interface{}

func (*SliceHandler) Init

func (s *SliceHandler) Init()

func (*SliceHandler) SetStatReaders

func (s *SliceHandler) SetStatReaders(containerID string, statReaders []StatReader)

type StatReader

type StatReader interface {
	Read() map[string]interface{}
}

Jump to

Keyboard shortcuts

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