internal

package
v0.0.0-...-304f10d Latest Latest
Warning

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

Go to latest
Published: Feb 20, 2023 License: BSD-3-Clause Imports: 14 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DumpNone   = 0
	DumpSignal = iota + 1000
	DumpCPU
	DumpMEM

	Dump100 = 100
	Dump200 = 200
	Dump300 = 300
	Dump400 = 400
	Dump500 = 500
	Dump600 = 600
	Dump700 = 700
	Dump800 = 800
	Dump900 = 900

	DumpEOF = 9999
)

Variables

View Source
var (
	ErrorBadCgroupInfo = errors.New("bad cgroup info")
	ErrorNoCpusetDir   = errors.New("no cpuset dir")
	ErrorNoCpuacctDir  = errors.New("no cpuacct dir")
	ErrorNoCpuDir      = errors.New("no cpu dir")
)
View Source
var (
	ErrorBadCPUStat = errors.New("bad cpu stat of /proc/stat")
)

Functions

func GetSingleInst

func GetSingleInst() *dProf

func ReadLine

func ReadLine(filename string) (string, error)

ReadLine 只读取第一行非空行

func ReadLines

func ReadLines(filename string) ([]string, error)

ReadLines 读取一个文件,去掉空行和多余的空格

Types

type Cgroup

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

func NewCgroup

func NewCgroup() *Cgroup

func (*Cgroup) GetCpus

func (cgroup *Cgroup) GetCpus() ([]uint64, error)

GetCpus 获取当前进程所属的cgroup可使用的cpu核心编号,所谓亲和 格式为 0-3,6

func (*Cgroup) GetPeriodUs

func (cgroup *Cgroup) GetPeriodUs() (uint64, error)

GetPeriodUs 获取当前进程所属的cgroup的时间周期,能使用的cpu核心数=cpu时间数/时间周期,单位us

func (*Cgroup) GetQuotaUs

func (cgroup *Cgroup) GetQuotaUs() (int64, error)

GetQuotaUs 获取当前进程所属的cgroup的每个时间周期可使用的cpu时间数,单位us,-1代表全部cpu时间数

func (*Cgroup) GetUsage

func (cgroup *Cgroup) GetUsage() (uint64, error)

func (*Cgroup) Init

func (c *Cgroup) Init() error

Init 获得当前进程所处的cgroup信息,目前只支持v1版本的cgroup

cgroup 文件的一般格式

10:cpuset:/
9:pids:/system.slice/tuned.service
8:blkio:/system.slice/tuned.service
7:hugetlb:/
6:devices:/system.slice/tuned.service
5:net_prio,net_cls:/
4:perf_event:/
3:cpuacct,cpu:/system.slice/tuned.service
2:freezer:/
1:name=systemd:/system.slice/tuned.service

type Stat

type Stat interface {
	Init() error            // 初始化
	UpdateCpuUsage() uint64 // 更新cpu使用率
}

type StatImpl

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

func NewStat

func NewStat() *StatImpl

func (*StatImpl) Init

func (s *StatImpl) Init() error

func (*StatImpl) UpdateCpuUsage

func (s *StatImpl) UpdateCpuUsage() uint64

Jump to

Keyboard shortcuts

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