cgroup

package
v0.0.0-...-3f388d4 Latest Latest
Warning

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

Go to latest
Published: Jun 8, 2022 License: Apache-2.0 Imports: 13 Imported by: 0

Documentation

Overview

-------------------------------------------------------------------------

*
* io.go
*    Read cgroup io metrics
*
*
* Copyright (c) 2021, Alibaba Group Holding Limited
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
* IDENTIFICATION
*           common/cgroup/io.go
*-------------------------------------------------------------------------

Index

Constants

This section is empty.

Variables

View Source
var Devices sync.Map

Functions

This section is empty.

Types

type CPUMem

type CPUMem struct {
	// contains filtered or unexported fields
}

func New

func New(buf *bytes.Buffer) *CPUMem

func (*CPUMem) GetCpuDetail

func (cm *CPUMem) GetCpuDetail() (*CpuDetail, error)

func (*CPUMem) GetCpuLimit

func (cm *CPUMem) GetCpuLimit() (uint64, error)

* 获取CGroup CPU 规格 对于CPUshare 场景,取cfs_quota_us/cfs_peroid_us 对于CPUSet 场景,取cpuset 由于线上配置问题,可能存在同时开启cpuset 和cpushare ,此时取两者的最小值。

func (*CPUMem) GetCpuStat

func (cm *CPUMem) GetCpuStat() (uint64, uint64, uint64, error)

func (*CPUMem) GetCpuUsage

func (cm *CPUMem) GetCpuUsage() (uint64, uint64, uint64, error)

func (*CPUMem) GetHugePageMemory

func (cm *CPUMem) GetHugePageMemory() (uint64, error)

func (*CPUMem) GetKernalMemoryUsage

func (cm *CPUMem) GetKernalMemoryUsage() (uint64, error)

func (*CPUMem) GetMaxUsageInBytes

func (cm *CPUMem) GetMaxUsageInBytes() (uint64, error)

func (*CPUMem) GetMemoryLimit

func (cm *CPUMem) GetMemoryLimit() (uint64, error)

func (*CPUMem) GetMemoryStat

func (cm *CPUMem) GetMemoryStat() (*MemoryStat, error)

func (*CPUMem) GetMemoryUsage

func (cm *CPUMem) GetMemoryUsage() (uint64, error)

func (*CPUMem) GetPerCpuUsage

func (cm *CPUMem) GetPerCpuUsage() ([]uint64, error)

func (*CPUMem) InitCpu

func (cm *CPUMem) InitCpu(path string) error

func (*CPUMem) InitHugePageMemory

func (cm *CPUMem) InitHugePageMemory(mmpath, mode string) error

func (*CPUMem) InitMemory

func (cm *CPUMem) InitMemory(path string) error

type CpuDetail

type CpuDetail struct {
	Usr              uint64
	Nice             uint64
	Sys              uint64
	IoWait           uint64
	Idle             uint64
	SoftIrq          uint64
	Irq              uint64
	NrRunning        uint64
	NrUnInterrupible uint64
	Load1            uint64
}

type DeviceUEvent

type DeviceUEvent struct {
	Major   string
	Minor   string
	DevName string
	DevType string
}

type Io

type Io struct {
	// contains filtered or unexported fields
}

func NewIo

func NewIo(buf *bytes.Buffer) *Io

NewIo build a new Io object

func (*Io) GetDiskIo

func (cio *Io) GetDiskIo() (uint64, uint64, uint64, uint64, string, string, error)

GetDiskIo get stat from /proc/diskstats

func (*Io) GetIOLimit

func (cio *Io) GetIOLimit() (stat *IoStat, err error)

get throttle iops limit

func (*Io) GetIo

func (cio *Io) GetIo() (stat *IoStat, err error)

GetIO return dataIo and logIo count

func (*Io) GetIoBytes

func (cio *Io) GetIoBytes() (*IoStat, error)

GetIO return dataIo and logIo bytes count

func (*Io) GetIoServiceTime

func (cio *Io) GetIoServiceTime() (stat *IoStat, err error)

func (*Io) GetIoWaitTime

func (cio *Io) GetIoWaitTime() (stat *IoStat, err error)

func (*Io) Init

func (cio *Io) Init(port int, onEcs bool) error

Init get dev number from mountinfo

func (*Io) InitPath

func (cio *Io) InitPath(blkPath string, onEcs bool) error

func (*Io) InitPathWithMp

func (cio *Io) InitPathWithMp(blkPath string, onEcs bool, dataDev string, logDev string) error

type IoStat

type IoStat struct {
	DataIo         uint64
	DataWIo        uint64
	DataRIo        uint64
	LogIo          uint64
	LogRIo         uint64
	LogWIo         uint64
	ReadIOPSLimit  uint64
	WriteIOPSLimit uint64
	ReadBpsLimit   uint64
	WriteBpsLimit  uint64
	RWaitTime      uint64
	WWaitTime      uint64
	WaitTime       uint64
	RServiceTime   uint64
	WServiceTime   uint64
	ServiceTime    uint64
}

type MemoryStat

type MemoryStat struct {
	Cache              uint64
	Rss                uint64
	RssHuge            uint64
	MappedFile         uint64
	Pgpgin             uint64
	Pgpgout            uint64
	Swap               uint64
	Dirty              uint64
	WriteBack          uint64
	WorkingSetReFault  uint64
	WorkingSetActivate uint64
	WorkingSetRestore  uint64
	InactiveAnon       uint64
	ActiveAnon         uint64
	InActiveFile       uint64
	ActiveFile         uint64
	UnEvictable        uint64
}

Jump to

Keyboard shortcuts

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