monitor

package
v0.0.30 Latest Latest
Warning

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

Go to latest
Published: Nov 6, 2025 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetPidByName

func GetPidByName(name string) ([]int, error)

GetPidByName 需要提供完整程序名字 rg:"foo.exe"

Types

type CPUCollector

type CPUCollector struct{}

CPUCollector CPU 使用率采集器

func NewCPUCollector

func NewCPUCollector() *CPUCollector

NewCPUCollector 初始化CPU采集器

func (*CPUCollector) Collect

func (c *CPUCollector) Collect(p *process.Process, _ time.Time) ([]string, error)

func (*CPUCollector) Names

func (c *CPUCollector) Names() []string

type Collector

type Collector interface {
	Names() []string
	Collect(p *process.Process, now time.Time) ([]string, error)
}

Collector 定义采集器接口

type DiskCollector

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

DiskCollector 磁盘采集器(必须初始化path)

func NewDiskCollector

func NewDiskCollector(path string) *DiskCollector

NewDiskCollector 初始化磁盘采集器

func (*DiskCollector) Collect

func (d *DiskCollector) Collect(_ *process.Process, _ time.Time) ([]string, error)

func (*DiskCollector) Names

func (d *DiskCollector) Names() []string

type IOCollector

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

IOCollector IO 采集器(含速率计算)

func NewIOCollector

func NewIOCollector() *IOCollector

NewIOCollector 初始化IO采集器(含速率计算)

func (*IOCollector) Collect

func (c *IOCollector) Collect(p *process.Process, now time.Time) ([]string, error)

func (*IOCollector) Names

func (c *IOCollector) Names() []string

type MemoryCollector

type MemoryCollector struct{}

MemoryCollector 内存采集器

func NewMemoryCollector

func NewMemoryCollector() *MemoryCollector

NewMemoryCollector 初始化内存采集器

func (*MemoryCollector) Collect

func (m *MemoryCollector) Collect(p *process.Process, _ time.Time) ([]string, error)

func (*MemoryCollector) Names

func (m *MemoryCollector) Names() []string

type Monitor

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

Monitor 监控器

func NewCustomMonitor

func NewCustomMonitor(pid int, interval time.Duration, collectors []Collector, writer fileio.Files) *Monitor

NewCustomMonitor 通用构造函数

func NewDefaultMonitor

func NewDefaultMonitor(pid int, path string) *Monitor

NewDefaultMonitor 默认构造函数

func (*Monitor) Run

func (m *Monitor) Run(ctx context.Context, showLog bool) error

Run 执行监控 用 ctx 管控整个生命周期

type NetCollector

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

NetCollector 网络信息采集器

func NewNetCollector

func NewNetCollector() *NetCollector

NewNetCollector 初始化网络采集器

func (*NetCollector) Collect

func (c *NetCollector) Collect(_ *process.Process, now time.Time) ([]string, error)

func (*NetCollector) Names

func (c *NetCollector) Names() []string

Jump to

Keyboard shortcuts

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