config

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Sep 24, 2026 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func FindConfigFile

func FindConfigFile(overridePath string) string

FindConfigFile searches for config files in standard locations.

func GetDefaultConfigPath

func GetDefaultConfigPath() string

GetDefaultConfigPath returns the default location for config.yaml.

Types

type AgentConfig

type AgentConfig struct {
	Enabled     bool   `yaml:"enabled"`
	Port        int    `yaml:"port"`
	BindAddress string `yaml:"bind_address"`
	Token       string `yaml:"token"`
	TLSCert     string `yaml:"tls_cert"`
	TLSKey      string `yaml:"tls_key"`
}

AgentConfig configures the remote agent server.

type AlertsConfig

type AlertsConfig struct {
	CPU     ThresholdAlert `yaml:"cpu"`
	Memory  ThresholdAlert `yaml:"memory"`
	Disk    ThresholdAlert `yaml:"disk"`
	Process ProcessAlert   `yaml:"process"`
	Network ThresholdAlert `yaml:"network"`
}

AlertsConfig bundles all alert thresholds.

type AnomalyConfig

type AnomalyConfig struct {
	Enabled         bool    `yaml:"enabled"`
	ZScoreThreshold float64 `yaml:"z_score_threshold"`
	WindowSize      int     `yaml:"window_size"`
	Alpha           float64 `yaml:"alpha"` // EWMA factor
}

AnomalyConfig configures the statistical anomaly detector.

type CollectorsConfig

type CollectorsConfig struct {
	CPU        bool `yaml:"cpu"`
	Memory     bool `yaml:"memory"`
	Disk       bool `yaml:"disk"`
	Network    bool `yaml:"network"`
	Process    bool `yaml:"process"`
	Service    bool `yaml:"service"`
	Port       bool `yaml:"port"`
	Docker     bool `yaml:"docker"`
	Kubernetes bool `yaml:"kubernetes"`
}

CollectorsConfig specifies which collectors are enabled.

type Config

type Config struct {
	RefreshInterval time.Duration    `yaml:"refresh_interval"`
	Storage         StorageConfig    `yaml:"storage"`
	Alerts          AlertsConfig     `yaml:"alerts"`
	Anomaly         AnomalyConfig    `yaml:"anomaly"`
	Collectors      CollectorsConfig `yaml:"collectors"`
	Dashboard       DashboardConfig  `yaml:"dashboard"`
	Prometheus      PrometheusConfig `yaml:"prometheus"`
	Agent           AgentConfig      `yaml:"agent"`
	Docker          DockerConfig     `yaml:"docker"`
	Kubernetes      KubernetesConfig `yaml:"kubernetes"`
}

Config is the root configuration structure for Watchdog.

func DefaultConfig

func DefaultConfig() *Config

DefaultConfig returns a fully populated, production-ready configuration.

func Load

func Load(path string) (*Config, string, error)

Load reads and parses config from disk or returns default if not found.

func (*Config) Save

func (c *Config) Save(path string) error

Save writes configuration to disk.

func (*Config) Validate

func (c *Config) Validate() error

Validate checks all settings for correctness.

type DashboardConfig

type DashboardConfig struct {
	Theme          string `yaml:"theme"`
	ShowPerCoreCPU bool   `yaml:"show_per_core_cpu"`
	ProcessSortBy  string `yaml:"process_sort_by"`
	ProcessLimit   int    `yaml:"process_limit"`
	PauseOnStart   bool   `yaml:"pause_on_start"`
}

DashboardConfig configures TUI appearance and defaults.

type DockerConfig

type DockerConfig struct {
	Enabled bool   `yaml:"enabled"`
	Host    string `yaml:"host"`
}

DockerConfig configures Docker container monitoring.

type KubernetesConfig

type KubernetesConfig struct {
	Enabled    bool   `yaml:"enabled"`
	Kubeconfig string `yaml:"kubeconfig"`
	Namespace  string `yaml:"namespace"`
}

KubernetesConfig configures Kubernetes monitoring.

type ProcessAlert

type ProcessAlert struct {
	Enabled         bool          `yaml:"enabled"`
	CPUThreshold    float64       `yaml:"cpu_threshold"`
	MemoryThreshold float64       `yaml:"memory_threshold"`
	Cooldown        time.Duration `yaml:"cooldown"`
}

ProcessAlert defines process-specific alert thresholds.

type PrometheusConfig

type PrometheusConfig struct {
	Enabled bool   `yaml:"enabled"`
	Port    int    `yaml:"port"`
	Path    string `yaml:"path"`
}

PrometheusConfig configures Prometheus metrics exporter.

type StorageConfig

type StorageConfig struct {
	Enabled            bool          `yaml:"enabled"`
	DBPath             string        `yaml:"db_path"`
	RetentionDays      int           `yaml:"retention_days"`
	CollectionInterval time.Duration `yaml:"collection_interval"`
}

StorageConfig configures SQLite storage for metric history.

type ThresholdAlert

type ThresholdAlert struct {
	Enabled   bool          `yaml:"enabled"`
	Threshold float64       `yaml:"threshold"`
	Duration  time.Duration `yaml:"duration"`
	Cooldown  time.Duration `yaml:"cooldown"`
}

ThresholdAlert defines metric alert threshold.

Jump to

Keyboard shortcuts

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