collect

package
v0.0.14 Latest Latest
Warning

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

Go to latest
Published: Mar 2, 2026 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrReporterRequired = &AgentError{message: "reporter function is required"}

ErrReporterRequired 错误:未提供上报函数

Functions

func NewAgentAdmin

func NewAgentAdmin(ctx context.Context, options ...ssh.Option) (agentAdmin, error)

Types

type Agent

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

Agent 通用采集器,定期采集本机信息并执行上报流程

func NewAgent

func NewAgent(opts ...Option) (*Agent, error)

NewAgent 创建新的Agent实例 如果未提供 Collector,将使用默认的 monitor.CollectStats Reporter 是必需的,如果未提供,将返回错误

func (*Agent) GetStats

func (a *Agent) GetStats() (map[string]interface{}, error)

GetStats 获取采集器统计信息

func (*Agent) IsRunning

func (a *Agent) IsRunning() bool

IsRunning 检查采集器是否正在运行

func (*Agent) Start

func (a *Agent) Start()

Start 启动采集器

func (*Agent) Stop

func (a *Agent) Stop()

Stop 停止采集器

type AgentError

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

AgentError Agent相关错误

func (*AgentError) Error

func (e *AgentError) Error() string

type ClientInfo

type ClientInfo struct {
	Hostname     string    `redis:"hostname"`
	LastReportAt time.Time `redis:"last_report_at"`
	CpuPercent   float64   `redis:"cpu_percent"`
	MemPercent   float64   `redis:"mem_percent"`
	DiskPercent  float64   `redis:"disk_percent"`
	NetBytesSent float64   `redis:"net_bytes_sent"`
	NetBytesRec  float64   `redis:"net_bytes_rec"`
	Version      string    `redis:"version"`
}

ClientInfo 客户端信息结构,用于Redis存储

type Option

type Option func(*Agent)

Option 配置选项函数类型

func WithCollector

func WithCollector(collector func() (*monitor.SystemStats, error)) Option

WithCollector 设置自定义数据收集函数 如果不设置,将使用默认的 monitor.CollectStats

func WithErrorHandler

func WithErrorHandler(onError func(error)) Option

WithErrorHandler 设置错误处理函数

func WithInterval

func WithInterval(interval time.Duration) Option

WithInterval 设置采集间隔

func WithReporter

func WithReporter(reporter func(*monitor.SystemStats) error) Option

WithReporter 设置数据上报函数 这是必需的选项,如果不设置,Agent 将无法上报数据

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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