Remove hardcoded defaults, require configuration file

- Remove all Default implementations from agent configuration structs
- Make configuration file required for agent startup
- Update NixOS module to generate complete agent.toml configuration
- Add comprehensive configuration options to NixOS module including:
  - Service include/exclude patterns for systemd collector
  - All thresholds and intervals
  - ZMQ communication settings
  - Notification and cache configuration
- Agent now fails fast if no configuration provided
- Eliminates configuration drift between defaults and NixOS settings
This commit is contained in:
2025-10-21 00:01:26 +02:00
parent 1e8da8c187
commit a937032eb1
6 changed files with 46 additions and 347 deletions

View File

@@ -1,54 +1,2 @@
// Collection intervals
pub const DEFAULT_COLLECTION_INTERVAL_SECONDS: u64 = 2;
pub const DEFAULT_CPU_INTERVAL_SECONDS: u64 = 5;
pub const DEFAULT_MEMORY_INTERVAL_SECONDS: u64 = 5;
pub const DEFAULT_DISK_INTERVAL_SECONDS: u64 = 300; // 5 minutes
pub const DEFAULT_PROCESS_INTERVAL_SECONDS: u64 = 30;
pub const DEFAULT_SYSTEMD_INTERVAL_SECONDS: u64 = 30;
pub const DEFAULT_SMART_INTERVAL_SECONDS: u64 = 900; // 15 minutes
pub const DEFAULT_BACKUP_INTERVAL_SECONDS: u64 = 900; // 15 minutes
pub const DEFAULT_NETWORK_INTERVAL_SECONDS: u64 = 30;
// ZMQ configuration
pub const DEFAULT_ZMQ_PUBLISHER_PORT: u16 = 6130;
pub const DEFAULT_ZMQ_COMMAND_PORT: u16 = 6131;
pub const DEFAULT_ZMQ_BIND_ADDRESS: &str = "0.0.0.0";
pub const DEFAULT_ZMQ_TIMEOUT_MS: u64 = 5000;
pub const DEFAULT_ZMQ_HEARTBEAT_INTERVAL_MS: u64 = 30000;
// CPU thresholds (production values from legacy)
pub const DEFAULT_CPU_LOAD_WARNING: f32 = 9.0;
pub const DEFAULT_CPU_LOAD_CRITICAL: f32 = 10.0;
pub const DEFAULT_CPU_TEMP_WARNING: f32 = 100.0; // Effectively disabled
pub const DEFAULT_CPU_TEMP_CRITICAL: f32 = 100.0; // Effectively disabled
// Memory thresholds (from legacy)
pub const DEFAULT_MEMORY_WARNING_PERCENT: f32 = 80.0;
pub const DEFAULT_MEMORY_CRITICAL_PERCENT: f32 = 95.0;
// Disk thresholds
pub const DEFAULT_DISK_WARNING_PERCENT: f32 = 80.0;
pub const DEFAULT_DISK_CRITICAL_PERCENT: f32 = 90.0;
// Process configuration
pub const DEFAULT_TOP_PROCESSES_COUNT: usize = 10;
// Service thresholds
pub const DEFAULT_SERVICE_MEMORY_WARNING_MB: f32 = 1000.0;
pub const DEFAULT_SERVICE_MEMORY_CRITICAL_MB: f32 = 2000.0;
// SMART thresholds
pub const DEFAULT_SMART_TEMP_WARNING: f32 = 60.0;
pub const DEFAULT_SMART_TEMP_CRITICAL: f32 = 70.0;
pub const DEFAULT_SMART_WEAR_WARNING: f32 = 80.0;
pub const DEFAULT_SMART_WEAR_CRITICAL: f32 = 90.0;
// Backup configuration
pub const DEFAULT_BACKUP_MAX_AGE_HOURS: u64 = 48;
// Notification configuration (from legacy)
pub const DEFAULT_SMTP_HOST: &str = "localhost";
pub const DEFAULT_SMTP_PORT: u16 = 25;
pub const DEFAULT_FROM_EMAIL: &str = "{hostname}@cmtec.se";
pub const DEFAULT_TO_EMAIL: &str = "cm@cmtec.se";
pub const DEFAULT_NOTIFICATION_RATE_LIMIT_MINUTES: u64 = 0;
// This file is now empty - all configuration values come from config files
// No hardcoded defaults are used