Documentation
¶
Index ¶
- func DefaultNetworkExcludePatterns() []string
- func GetDefaultConfigPath() string
- type AgentConfig
- type AutoUpdateConfig
- type CollectorConfig
- type Config
- func (c *Config) Endpoint() string
- func (c *Config) GetCollectorInterval() time.Duration
- func (c *Config) GetDiskInclude() []string
- func (c *Config) GetDownloadURL() string
- func (c *Config) GetHeartbeatInterval() time.Duration
- func (c *Config) GetLatestVersionURL() string
- func (c *Config) GetNetworkExcludePatterns() ([]*regexp.Regexp, error)
- func (c *Config) GetNetworkIncludePatterns() ([]*regexp.Regexp, error)
- func (c *Config) GetUpdateCheckInterval() time.Duration
- func (c *Config) GetWebSocketURL() string
- func (c *Config) Save(path string) error
- func (c *Config) ShouldExcludeNetworkInterface(interfaceName string) bool
- func (c *Config) ShouldIncludeDiskMountPoint(mountPoint string) bool
- func (c *Config) Validate() error
- type ServerConfig
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func DefaultNetworkExcludePatterns ¶
func DefaultNetworkExcludePatterns() []string
Types ¶
type AgentConfig ¶
type AgentConfig struct {
// Agent 名称(默认使用主机名)
Name string `yaml:"name"`
// 日志等级(debug, info, warn, error,默认为 info)
LogLevel string `yaml:"log_level"`
// 日志文件路径(默认为空,输出到控制台)
LogFile string `yaml:"log_file"`
// 日志文件最大大小(MB,默认 100MB)
LogMaxSize int `yaml:"log_max_size"`
// 日志文件最大备份数(默认 3)
LogMaxBackups int `yaml:"log_max_backups"`
// 日志文件最大保留天数(默认 28 天)
LogMaxAge int `yaml:"log_max_age"`
// 是否压缩旧日志文件(默认 true)
LogCompress bool `yaml:"log_compress"`
}
AgentConfig Agent 配置
type AutoUpdateConfig ¶
type AutoUpdateConfig struct {
// 是否启用自动更新
Enabled bool `yaml:"enabled"`
// 检查更新间隔
CheckInterval string `yaml:"check_interval"`
}
AutoUpdateConfig 自动更新配置
type CollectorConfig ¶
type CollectorConfig struct {
// 数据采集间隔(秒)
Interval int `yaml:"interval"`
// 心跳间隔(秒)
HeartbeatInterval int `yaml:"heartbeat_interval"`
// 网络采集包含的网卡列表(白名单,支持正则表达式)
// 如果配置了此项,则只采集匹配的网卡,忽略 NetworkExclude
// 例如: ["^eth0$", "^en0$", "^ens.*"]
NetworkInclude []string `yaml:"network_include"`
// 网络采集排除的网卡列表(黑名单,支持正则表达式)
// 仅当 NetworkInclude 为空时生效
// 如果为空,使用默认排除规则(虚拟网卡、回环地址等)
NetworkExclude []string `yaml:"network_exclude"`
// 磁盘采集包含的挂载点列表(白名单)
// 如果为空,默认采集系统主分区(Linux/macOS: "/",Windows: "C:\")
// 例如:
// Linux/macOS: ["/", "/data", "/home"]
// Windows: ["C:", "D:"]
DiskInclude []string `yaml:"disk_include"`
}
CollectorConfig 采集器配置
type Config ¶
type Config struct {
// 配置文件路径
Path string `yaml:"-"`
// 服务器配置
Server ServerConfig `yaml:"server"`
// Agent 配置
Agent AgentConfig `yaml:"agent"`
// 采集配置
Collector CollectorConfig `yaml:"collector"`
// 自动更新配置
AutoUpdate AutoUpdateConfig `yaml:"auto_update"`
}
Config Agent 配置
func (*Config) GetCollectorInterval ¶
GetCollectorInterval 获取采集间隔时长
func (*Config) GetDiskInclude ¶
GetDiskInclude 获取磁盘包含的挂载点列表(白名单) 如果配置为空,返回默认的根分区匹配规则 Linux/macOS: ["/"] Windows: ["C:"]
func (*Config) GetDownloadURL ¶
func (*Config) GetHeartbeatInterval ¶
GetHeartbeatInterval 获取心跳间隔时长
func (*Config) GetLatestVersionURL ¶
GetLatestVersionURL 获取更新检查地址
func (*Config) GetNetworkExcludePatterns ¶
GetNetworkExcludePatterns 获取网络排除的正则表达式列表 如果配置为空,返回默认排除规则(回环地址和常见虚拟网卡)
func (*Config) GetNetworkIncludePatterns ¶
GetNetworkIncludePatterns 获取网络包含的正则表达式列表(白名单)
func (*Config) GetUpdateCheckInterval ¶
GetUpdateCheckInterval 获取更新检查间隔时长
func (*Config) GetWebSocketURL ¶
GetWebSocketURL 获取 WebSocket 连接地址
func (*Config) ShouldExcludeNetworkInterface ¶
ShouldExcludeNetworkInterface 检查网卡是否应该被排除 逻辑: 1. 如果配置了 NetworkInclude(白名单),则只保留匹配白名单的网卡 2. 如果没有配置 NetworkInclude,则使用 NetworkExclude(黑名单)规则
func (*Config) ShouldIncludeDiskMountPoint ¶
ShouldIncludeDiskMountPoint 检查挂载点是否应该被采集 只有在 DiskInclude 白名单中的挂载点才会被采集
type ServerConfig ¶
type ServerConfig struct {
// 服务器地址(如:http://localhost:18888 或 https://your-server.com)
Endpoint string `yaml:"endpoint"`
// API Key
APIKey string `yaml:"api_key"`
// 是否跳过 TLS 证书验证(仅用于测试环境,生产环境不建议开启)
InsecureSkipVerify bool `yaml:"insecure_skip_verify"`
}
ServerConfig 服务器配置