diff --git a/agent/src/cache/cached_metric.rs b/agent/src/cache/cached_metric.rs index 669b362..de2260e 100644 --- a/agent/src/cache/cached_metric.rs +++ b/agent/src/cache/cached_metric.rs @@ -1,4 +1,4 @@ -use cm_dashboard_shared::{CacheTier, Metric}; +use cm_dashboard_shared::Metric; use std::time::Instant; /// A cached metric with metadata @@ -7,5 +7,4 @@ pub struct CachedMetric { pub metric: Metric, pub collected_at: Instant, pub access_count: u64, - pub tier: Option, } diff --git a/agent/src/cache/mod.rs b/agent/src/cache/mod.rs index fd95b08..c3f681e 100644 --- a/agent/src/cache/mod.rs +++ b/agent/src/cache/mod.rs @@ -41,7 +41,6 @@ impl ConfigurableCache { metric: metric.clone(), collected_at: Instant::now(), access_count: 1, - tier: self.config.get_tier_for_metric(&metric.name).cloned(), }; cache.insert(metric.name.clone(), cached_metric); diff --git a/agent/src/collectors/cpu.rs b/agent/src/collectors/cpu.rs index e96d7ad..7c5eb36 100644 --- a/agent/src/collectors/cpu.rs +++ b/agent/src/collectors/cpu.rs @@ -15,7 +15,6 @@ use crate::config::CpuConfig; /// - No process spawning /// - <0.1ms collection time target pub struct CpuCollector { - config: CpuConfig, name: String, load_thresholds: HysteresisThresholds, temperature_thresholds: HysteresisThresholds, @@ -35,7 +34,6 @@ impl CpuCollector { ); Self { - config, name: "cpu".to_string(), load_thresholds, temperature_thresholds, @@ -243,7 +241,4 @@ impl Collector for CpuCollector { Ok(metrics) } - fn get_performance_metrics(&self) -> Option { - None // Performance tracking handled by cache system - } } diff --git a/agent/src/collectors/disk.rs b/agent/src/collectors/disk.rs index ee8a532..8081857 100644 --- a/agent/src/collectors/disk.rs +++ b/agent/src/collectors/disk.rs @@ -9,7 +9,7 @@ use std::process::Command; use std::time::Instant; use tracing::debug; -use super::{Collector, CollectorError, PerformanceMetrics}; +use super::{Collector, CollectorError}; /// Information about a mounted disk #[derive(Debug, Clone)] @@ -22,7 +22,6 @@ struct MountedDisk { used: String, // e.g., "45G" available: String, // e.g., "75G" usage_percent: f32, // e.g., 38.5 - config_name: Option, // Name from config if UUID-based } /// Disk usage collector for monitoring filesystem sizes @@ -117,7 +116,6 @@ impl DiskCollector { used, available, usage_percent: usage_percent as f32, - config_name: Some(fs_config.name.clone()), }); debug!( @@ -611,7 +609,4 @@ impl Collector for DiskCollector { Ok(metrics) } - fn get_performance_metrics(&self) -> Option { - None // Performance tracking handled by cache system - } } diff --git a/agent/src/collectors/memory.rs b/agent/src/collectors/memory.rs index bbbfc6e..b486801 100644 --- a/agent/src/collectors/memory.rs +++ b/agent/src/collectors/memory.rs @@ -15,7 +15,6 @@ use crate::config::MemoryConfig; /// - No regex or complex parsing /// - <0.1ms collection time target pub struct MemoryCollector { - config: MemoryConfig, name: String, usage_thresholds: HysteresisThresholds, } @@ -43,7 +42,6 @@ impl MemoryCollector { ); Self { - config, name: "memory".to_string(), usage_thresholds, } @@ -231,7 +229,4 @@ impl Collector for MemoryCollector { Ok(metrics) } - fn get_performance_metrics(&self) -> Option { - None // Performance tracking handled by cache system - } } diff --git a/agent/src/collectors/mod.rs b/agent/src/collectors/mod.rs index d2bbec8..36814fa 100644 --- a/agent/src/collectors/mod.rs +++ b/agent/src/collectors/mod.rs @@ -1,13 +1,6 @@ use async_trait::async_trait; use cm_dashboard_shared::{Metric, StatusTracker}; -use std::time::Duration; -/// Performance metrics for a collector -#[derive(Debug, Clone)] -pub struct PerformanceMetrics { - pub last_collection_time: Duration, - pub collection_efficiency_percent: f32, -} pub mod backup; pub mod cpu; @@ -28,10 +21,6 @@ pub trait Collector: Send + Sync { /// Collect all metrics this collector provides async fn collect(&self, status_tracker: &mut StatusTracker) -> Result, CollectorError>; - /// Get performance metrics for monitoring collector efficiency - fn get_performance_metrics(&self) -> Option { - None - } } diff --git a/agent/src/collectors/systemd.rs b/agent/src/collectors/systemd.rs index aa7bda6..ca9e4c1 100644 --- a/agent/src/collectors/systemd.rs +++ b/agent/src/collectors/systemd.rs @@ -6,12 +6,10 @@ use std::sync::RwLock; use std::time::Instant; use tracing::debug; -use super::{Collector, CollectorError, PerformanceMetrics}; +use super::{Collector, CollectorError}; /// Systemd collector for monitoring systemd services pub struct SystemdCollector { - /// Performance tracking - last_collection_time: Option, /// Cached state with thread-safe interior mutability state: RwLock, } @@ -36,7 +34,6 @@ struct ServiceCacheState { impl SystemdCollector { pub fn new() -> Self { Self { - last_collection_time: None, state: RwLock::new(ServiceCacheState { monitored_services: Vec::new(), last_discovery_time: None, @@ -481,9 +478,6 @@ impl Collector for SystemdCollector { Ok(metrics) } - fn get_performance_metrics(&self) -> Option { - None // Performance tracking handled by cache system - } } impl SystemdCollector { @@ -755,7 +749,6 @@ impl SystemdCollector { fn parse_server_block(&self, lines: &[&str], start_index: &mut usize) -> Option { use tracing::debug; let mut server_names = Vec::new(); - let mut proxy_pass_url = None; let mut has_redirect = false; let mut i = *start_index + 1; let mut brace_count = 1; @@ -785,16 +778,6 @@ impl SystemdCollector { } } - // Extract proxy_pass URL (backend IP:port) - if trimmed.starts_with("proxy_pass") { - if let Some(url_part) = trimmed.strip_prefix("proxy_pass") { - let url_clean = url_part.trim().trim_end_matches(';'); - if !url_clean.is_empty() { - proxy_pass_url = Some(url_clean.to_string()); - debug!("Found proxy_pass in block: {}", url_clean); - } - } - } // Check for redirects (skip redirect-only servers) if trimmed.contains("return") && (trimmed.contains("301") || trimmed.contains("302")) { diff --git a/agent/src/communication/mod.rs b/agent/src/communication/mod.rs index 235e8b7..9a0c004 100644 --- a/agent/src/communication/mod.rs +++ b/agent/src/communication/mod.rs @@ -9,7 +9,6 @@ use crate::config::ZmqConfig; pub struct ZmqHandler { publisher: Socket, command_receiver: Socket, - config: ZmqConfig, } impl ZmqHandler { @@ -41,7 +40,6 @@ impl ZmqHandler { Ok(Self { publisher, command_receiver, - config: config.clone(), }) } diff --git a/agent/src/metrics/mod.rs b/agent/src/metrics/mod.rs index 191d26a..ca898f1 100644 --- a/agent/src/metrics/mod.rs +++ b/agent/src/metrics/mod.rs @@ -237,21 +237,6 @@ impl MetricCollectionManager { Ok(all_metrics) } - /// Get names of all registered collectors - pub fn get_collector_names(&self) -> Vec { - self.collectors - .iter() - .map(|c| c.name().to_string()) - .collect() - } - - /// Get collector statistics - pub fn get_stats(&self) -> HashMap { - self.collectors - .iter() - .map(|c| (c.name().to_string(), true)) // All collectors are enabled - .collect() - } /// Get all cached metrics from the cache manager pub async fn get_all_cached_metrics(&self) -> Result> { @@ -263,20 +248,4 @@ impl MetricCollectionManager { Ok(cached_metrics) } - /// Determine which collector handles a specific metric - fn get_collector_for_metric(&self, metric_name: &str) -> String { - if metric_name.starts_with("cpu_") { - "cpu".to_string() - } else if metric_name.starts_with("memory_") { - "memory".to_string() - } else if metric_name.starts_with("disk_") { - "disk".to_string() - } else if metric_name.starts_with("service_") { - "systemd".to_string() - } else if metric_name.starts_with("backup_") { - "backup".to_string() - } else { - "unknown".to_string() - } - } } diff --git a/agent/src/notifications/mod.rs b/agent/src/notifications/mod.rs index 62c0d1d..0940e8a 100644 --- a/agent/src/notifications/mod.rs +++ b/agent/src/notifications/mod.rs @@ -295,8 +295,4 @@ impl NotificationManager { } } - /// Get current metric statuses - pub fn get_metric_statuses(&self) -> &HashMap { - &self.metric_statuses - } } diff --git a/agent/src/utils/mod.rs b/agent/src/utils/mod.rs index de66f0a..58bd38e 100644 --- a/agent/src/utils/mod.rs +++ b/agent/src/utils/mod.rs @@ -1,91 +1 @@ -// Utility functions for the agent - -/// System information utilities -pub mod system { - use std::fs; - - /// Get number of CPU cores efficiently - pub fn get_cpu_count() -> Result { - // Try /proc/cpuinfo first (most reliable) - if let Ok(content) = fs::read_to_string("/proc/cpuinfo") { - let count = content - .lines() - .filter(|line| line.starts_with("processor")) - .count(); - - if count > 0 { - return Ok(count); - } - } - - // Fallback to nproc equivalent - match std::thread::available_parallelism() { - Ok(count) => Ok(count.get()), - Err(_) => Ok(1), // Default to 1 core if all else fails - } - } - - /// Check if running in container - pub fn is_container() -> bool { - // Check for common container indicators - fs::metadata("/.dockerenv").is_ok() - || fs::read_to_string("/proc/1/cgroup") - .map(|content| content.contains("docker") || content.contains("containerd")) - .unwrap_or(false) - } -} - -/// Time utilities -pub mod time { - use std::time::{Duration, Instant}; - - /// Measure execution time of a closure - pub fn measure_time(f: F) -> (R, Duration) - where - F: FnOnce() -> R, - { - let start = Instant::now(); - let result = f(); - let duration = start.elapsed(); - (result, duration) - } -} - -/// Performance monitoring utilities -pub mod perf { - use std::time::{Duration, Instant}; - use tracing::warn; - - /// Performance monitor for critical operations - pub struct PerfMonitor { - operation: String, - start: Instant, - warning_threshold: Duration, - } - - impl PerfMonitor { - pub fn new(operation: &str, warning_threshold: Duration) -> Self { - Self { - operation: operation.to_string(), - start: Instant::now(), - warning_threshold, - } - } - - pub fn new_ms(operation: &str, warning_threshold_ms: u64) -> Self { - Self::new(operation, Duration::from_millis(warning_threshold_ms)) - } - } - - impl Drop for PerfMonitor { - fn drop(&mut self) { - let elapsed = self.start.elapsed(); - if elapsed > self.warning_threshold { - warn!( - "Performance warning: {} took {:?} (threshold: {:?})", - self.operation, elapsed, self.warning_threshold - ); - } - } - } -} +// Utility functions for the agent (empty module) \ No newline at end of file diff --git a/dashboard/src/ui/mod.rs b/dashboard/src/ui/mod.rs index 1e36bf1..8444fed 100644 --- a/dashboard/src/ui/mod.rs +++ b/dashboard/src/ui/mod.rs @@ -140,9 +140,6 @@ impl TuiApp { // Get the current hostname (localhost) for auto-selection let localhost = gethostname::gethostname().to_string_lossy().to_string(); - - // Prioritize localhost if it becomes available, but respect user navigation - let localhost = gethostname::gethostname().to_string_lossy().to_string(); if !self.available_hosts.is_empty() { if self.available_hosts.contains(&localhost) && !self.user_navigated_away { // Localhost is available and user hasn't navigated away - switch to it