config

package
v0.50.0 Latest Latest
Warning

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

Go to latest
Published: Jul 13, 2026 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Path

func Path() string

Path returns ~/.config/xtop/config.json (or XDG_CONFIG_HOME). Returns empty string if home directory cannot be determined.

func Save

func Save(cfg Config) error

Save writes the config to disk.

Types

type AlertConfig

type AlertConfig struct {
	Webhook          string `json:"webhook"`
	Command          string `json:"command"`
	Email            string `json:"email"`
	SlackWebhook     string `json:"slack_webhook"`
	TelegramBotToken string `json:"telegram_bot_token"`
	TelegramChatID   string `json:"telegram_chat_id"`
}

type AutopilotConfig

type AutopilotConfig struct {
	Enabled            bool     `json:"enabled"`
	AutoConfirm        bool     `json:"auto_confirm"`
	ProtectedServices  []string `json:"protected_services,omitempty"`
	MaxCPUQuotaUs      int      `json:"max_cpu_quota_us,omitempty"`
	MaxMemLimitMB      int      `json:"max_mem_limit_mb,omitempty"`
	RollbackTimeoutSec int      `json:"rollback_timeout_sec,omitempty"`
}

AutopilotConfig configures the safe autopilot subsystem.

type Config

type Config struct {
	DefaultLayout    int                   `json:"default_layout"`
	IntervalSec      int                   `json:"interval_sec"`
	HistorySize      int                   `json:"history_size"`
	Section          string                `json:"default_section"`
	Prometheus       PrometheusConfig      `json:"prometheus"`
	Alerts           AlertConfig           `json:"alerts"`
	ServerIdentity   *model.ServerIdentity `json:"server_identity,omitempty"`
	CriticalServices []string              `json:"critical_services,omitempty"`
	ThresholdProfile string                `json:"threshold_profile,omitempty"`
	ExperienceLevel  string                `json:"experience_level,omitempty"` // "beginner", "advanced", or "" (first run)
	Autopilot        AutopilotConfig       `json:"autopilot,omitempty"`
	SLO              SLOConfig             `json:"slo,omitempty"`
	RCAThresholds    RCAThresholds         `json:"rca_thresholds,omitempty"`
}

Config holds user-configurable defaults and integrations.

func Default

func Default() Config

Default returns a config with sensible defaults.

func Load

func Load() Config

Load loads config from disk; returns defaults on error. Auto-upgrades stale values from old versions (e.g., interval_sec: 1 → 3).

type PrometheusConfig

type PrometheusConfig struct {
	Enabled bool   `json:"enabled"`
	Addr    string `json:"addr"`
}

type RCAThresholds

type RCAThresholds struct {
	// ScoreCritical: PrimaryScore >= this → Health=Critical (default 60)
	ScoreCritical int `json:"score_critical,omitempty"`
	// ScoreDegraded: PrimaryScore >= this → Health=Degraded (default 25)
	ScoreDegraded int `json:"score_degraded,omitempty"`
	// ScoreFloor: scores below this are zeroed as noise (default 20)
	ScoreFloor int `json:"score_floor,omitempty"`
	// MinIOPSForLatency: ignore devices with fewer IOPS/s (default 10.0)
	MinIOPSForLatency float64 `json:"min_iops_for_latency,omitempty"`
	// IoFsFullFreePct: free% below this triggers filesystem-full evidence (default 15.0)
	IoFsFullFreePct float64 `json:"io_fs_full_free_pct,omitempty"`
	// IoDstateBumpScore: forced IO score when D-state task count is high (default 60)
	IoDstateBumpScore int `json:"io_dstate_bump_score,omitempty"`
	// MemOOMMinScore: floor score when OOM kill detected + trust gate passes (default 70)
	MemOOMMinScore int `json:"mem_oom_min_score,omitempty"`
	// MemSafeAvailPct: avail% above this + low PSI dampens memory score (default 25.0)
	MemSafeAvailPct float64 `json:"mem_safe_avail_pct,omitempty"`
	// CpuSafeBusyPct: busy% below this + low PSI dampens CPU score (default 50.0)
	CpuSafeBusyPct float64 `json:"cpu_safe_busy_pct,omitempty"`
	// JvmHeapPressurePct: JVM heap used% above this emits pressure evidence (default 80.0)
	JvmHeapPressurePct float64 `json:"jvm_heap_pressure_pct,omitempty"`
}

RCAThresholds holds operator-tunable RCA scoring thresholds. Zero values (or omitted fields) fall back to the compiled-in defaults, so omitting this block entirely preserves existing behavior. Note: explicit 0 values are treated as "use default" — 0 cannot be set as an actual threshold value.

type SLOConfig

type SLOConfig struct {
	Policies []SLOPolicyConfig `json:"policies,omitempty"`
}

SLOConfig holds SLO policy configuration.

type SLOPolicyConfig

type SLOPolicyConfig struct {
	Name string `json:"name"` // e.g. "cpu<80%", "io_psi<5%"
}

SLOPolicyConfig is a named SLO policy string.

Jump to

Keyboard shortcuts

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