monitor

package
v3.0.0-...-42de6d8 Latest Latest
Warning

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

Go to latest
Published: Dec 17, 2024 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

View Source
const (
	CGroupCpuQuotaPath  = "/sys/fs/cgroup/cpu/cpu.cfs_quota_us"
	CGroupCpuPeriodPath = "/sys/fs/cgroup/cpu/cpu.cfs_period_us"
	CGroupMemLimitPath  = "/sys/fs/cgroup/memory/memory.limit_in_bytes"
)

Variables

View Source
var SysMonitor = &sysMonitor{status: &SysStatus{}}

Functions

func Start

func Start(collectDuration time.Duration, inCGroup bool)

Types

type CGProcessInterface

type CGProcessInterface interface {
	Percent(interval time.Duration) (float64, error)
	MemoryInfo() (*process.MemoryInfoStat, error)
}

type CGroupCollector

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

func NewCGroupCollector

func NewCGroupCollector(readUint ReadUintFunc) (*CGroupCollector, error)

func (*CGroupCollector) CpuPercent

func (c *CGroupCollector) CpuPercent() (float64, error)

func (*CGroupCollector) MemPercent

func (c *CGroupCollector) MemPercent() (float64, error)

type NormalCollector

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

func NewNormalCollector

func NewNormalCollector() (*NormalCollector, error)

func (*NormalCollector) CpuPercent

func (n *NormalCollector) CpuPercent() (float64, error)

func (*NormalCollector) MemPercent

func (n *NormalCollector) MemPercent() (float64, error)

type ProcessInterface

type ProcessInterface interface {
	Percent(interval time.Duration) (float64, error)
	MemoryPercent() (float32, error)
	MemoryInfo() (*process.MemoryInfoStat, error)
}

type ReadUintFunc

type ReadUintFunc func(path string) (uint64, error)

type SysCollector

type SysCollector interface {
	CpuPercent() (float64, error)
	MemPercent() (float64, error)
}

type SysStatus

type SysStatus struct {
	CollectTime     time.Time
	CpuPercent      float64
	CpuError        error
	MemPercent      float64
	MemError        error
	GoroutineCounts int
	ThreadCounts    int
}

Jump to

Keyboard shortcuts

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