diff --git a/agent/src/cache/manager.rs b/agent/src/cache/manager.rs index 517d4f8..dc3c957 100644 --- a/agent/src/cache/manager.rs +++ b/agent/src/cache/manager.rs @@ -1,8 +1,7 @@ use super::ConfigurableCache; use cm_dashboard_shared::{CacheConfig, Metric}; use std::sync::Arc; -use tokio::time::{interval, Duration}; -use tracing::{debug, info}; +use tracing::info; /// Manages metric caching with background tasks pub struct MetricCacheManager { diff --git a/agent/src/cache/mod.rs b/agent/src/cache/mod.rs index 488f862..160e74b 100644 --- a/agent/src/cache/mod.rs +++ b/agent/src/cache/mod.rs @@ -2,7 +2,7 @@ use cm_dashboard_shared::{CacheConfig, Metric}; use std::collections::HashMap; use std::time::Instant; use tokio::sync::RwLock; -use tracing::{debug, warn}; +use tracing::warn; mod manager; mod cached_metric; @@ -167,7 +167,7 @@ impl ConfigurableCache { let cache = self.cache.read().await; let mut stats_by_tier = HashMap::new(); - for (metric_name, cached_metric) in cache.iter() { + for (_metric_name, cached_metric) in cache.iter() { let tier_name = cached_metric.tier .as_ref() .map(|t| t.description.clone()) diff --git a/agent/src/collectors/backup.rs b/agent/src/collectors/backup.rs index 5e3e85f..33b5d7f 100644 --- a/agent/src/collectors/backup.rs +++ b/agent/src/collectors/backup.rs @@ -1,12 +1,11 @@ use async_trait::async_trait; -use cm_dashboard_shared::{Metric, MetricValue, Status, SharedError}; -use chrono::{DateTime, Utc}; +use cm_dashboard_shared::{Metric, MetricValue, Status}; +use chrono::Utc; use serde::{Deserialize, Serialize}; use std::collections::HashMap; -use std::path::Path; use tokio::fs; -use super::{Collector, CollectorError, utils}; +use super::{Collector, CollectorError}; use tracing::error; /// Backup collector that reads TOML status files for borgbackup metrics diff --git a/agent/src/collectors/cpu.rs b/agent/src/collectors/cpu.rs index 8da4ecf..3da4ee5 100644 --- a/agent/src/collectors/cpu.rs +++ b/agent/src/collectors/cpu.rs @@ -1,6 +1,6 @@ use async_trait::async_trait; use cm_dashboard_shared::{Metric, MetricValue, Status, registry}; -use std::time::Duration; + use tracing::debug; use super::{Collector, CollectorError, utils}; diff --git a/agent/src/collectors/disk.rs b/agent/src/collectors/disk.rs index d3dcbdb..43e7062 100644 --- a/agent/src/collectors/disk.rs +++ b/agent/src/collectors/disk.rs @@ -1,7 +1,7 @@ use anyhow::Result; use async_trait::async_trait; use cm_dashboard_shared::{Metric, MetricValue, Status}; -use std::collections::HashMap; + use std::process::Command; use std::time::Instant; use tracing::debug; @@ -398,7 +398,7 @@ impl Collector for DiskCollector { } // Add SMART health metrics for each unique physical device - for (physical_device, disks) in physical_devices { + for (physical_device, _disks) in physical_devices { let (health_status, temperature) = self.get_smart_health(&physical_device); let device_name = physical_device.strip_prefix("/dev/").unwrap_or(&physical_device); let timestamp = chrono::Utc::now().timestamp() as u64; diff --git a/agent/src/collectors/memory.rs b/agent/src/collectors/memory.rs index f061a76..9cfbb81 100644 --- a/agent/src/collectors/memory.rs +++ b/agent/src/collectors/memory.rs @@ -1,6 +1,6 @@ use async_trait::async_trait; use cm_dashboard_shared::{Metric, MetricValue, Status, registry}; -use std::time::Duration; + use tracing::debug; use super::{Collector, CollectorError, utils}; diff --git a/agent/src/collectors/mod.rs b/agent/src/collectors/mod.rs index d486601..0ba52c9 100644 --- a/agent/src/collectors/mod.rs +++ b/agent/src/collectors/mod.rs @@ -1,5 +1,5 @@ use async_trait::async_trait; -use cm_dashboard_shared::{Metric, SharedError}; +use cm_dashboard_shared::Metric; use std::time::Duration; pub mod cached_collector; diff --git a/agent/src/communication/mod.rs b/agent/src/communication/mod.rs index f1f337f..075deb6 100644 --- a/agent/src/communication/mod.rs +++ b/agent/src/communication/mod.rs @@ -1,6 +1,6 @@ use anyhow::Result; use cm_dashboard_shared::{MetricMessage, MessageEnvelope}; -use tracing::{info, error, debug}; +use tracing::{info, debug}; use zmq::{Context, Socket, SocketType}; use crate::config::ZmqConfig; diff --git a/agent/src/metrics/mod.rs b/agent/src/metrics/mod.rs index 56283e5..e76d39e 100644 --- a/agent/src/metrics/mod.rs +++ b/agent/src/metrics/mod.rs @@ -5,7 +5,7 @@ use std::time::Instant; use tracing::{info, error, debug}; use crate::config::{CollectorConfig, AgentConfig}; -use crate::collectors::{Collector, cpu::CpuCollector, memory::MemoryCollector, disk::DiskCollector, systemd::SystemdCollector, backup::BackupCollector, cached_collector::CachedCollector}; +use crate::collectors::{Collector, cpu::CpuCollector, memory::MemoryCollector, disk::DiskCollector, systemd::SystemdCollector, backup::BackupCollector}; use crate::cache::MetricCacheManager; /// Manages all metric collectors with intelligent caching @@ -195,7 +195,7 @@ impl MetricCollectionManager { } } } else { - let elapsed = self.last_collection_times.get(collector_name) + let _elapsed = self.last_collection_times.get(collector_name) .map(|t| now.duration_since(*t).as_secs()) .unwrap_or(0); // Collector skipped (debug logging disabled for performance) diff --git a/agent/src/notifications/mod.rs b/agent/src/notifications/mod.rs index 273366e..0eafed4 100644 --- a/agent/src/notifications/mod.rs +++ b/agent/src/notifications/mod.rs @@ -1,7 +1,7 @@ use cm_dashboard_shared::Status; use std::collections::HashMap; use std::time::Instant; -use tracing::{info, debug, warn}; +use tracing::{info, debug}; use crate::config::NotificationConfig; diff --git a/config/dashboard.toml b/config/dashboard.toml deleted file mode 100644 index ade331c..0000000 --- a/config/dashboard.toml +++ /dev/null @@ -1,41 +0,0 @@ -# CM Dashboard configuration - -[hosts] -# default_host = "srv01" - -[[hosts.hosts]] -name = "srv01" -enabled = true -# metadata = { rack = "R1" } - -[[hosts.hosts]] -name = "labbox" -enabled = true - -[[hosts.hosts]] -name = "srv02" -enabled = true - -[dashboard] -tick_rate_ms = 250 -history_duration_minutes = 60 - -[[dashboard.widgets]] -id = "nvme" -enabled = true - -[[dashboard.widgets]] -id = "services" -enabled = true - -[[dashboard.widgets]] -id = "backup" -enabled = true - -[[dashboard.widgets]] -id = "alerts" -enabled = true - -[filesystem] -# cache_dir = "/var/lib/cm-dashboard/cache" -# history_dir = "/var/lib/cm-dashboard/history" diff --git a/dashboard/src/app.rs b/dashboard/src/app.rs index a7cb073..0b2f3d2 100644 --- a/dashboard/src/app.rs +++ b/dashboard/src/app.rs @@ -57,20 +57,8 @@ impl Dashboard { } }; - // Connect to predefined hosts - let hosts = if config.hosts.predefined_hosts.is_empty() { - vec![ - "localhost".to_string(), - "cmbox".to_string(), - "labbox".to_string(), - "simonbox".to_string(), - "steambox".to_string(), - "srv01".to_string(), - "srv02".to_string(), - ] - } else { - config.hosts.predefined_hosts.clone() - }; + // Connect to predefined hosts from configuration + let hosts = config.hosts.predefined_hosts.clone(); // Try to connect to hosts but don't fail if none are available match zmq_consumer.connect_to_predefined_hosts(&hosts).await { @@ -139,11 +127,6 @@ impl Dashboard { self.zmq_command_sender.send_command(hostname, command).await } - /// Send a command to all connected hosts - pub async fn broadcast_command(&mut self, command: AgentCommand) -> Result> { - let connected_hosts = self.metric_store.get_connected_hosts(Duration::from_secs(30)); - self.zmq_command_sender.broadcast_command(&connected_hosts, command).await - } pub async fn run(&mut self) -> Result<()> { info!("Starting dashboard main loop"); diff --git a/dashboard/src/communication/mod.rs b/dashboard/src/communication/mod.rs index 2a459a5..aa3fe7c 100644 --- a/dashboard/src/communication/mod.rs +++ b/dashboard/src/communication/mod.rs @@ -2,7 +2,6 @@ use anyhow::Result; use cm_dashboard_shared::{MetricMessage, MessageEnvelope, MessageType}; use tracing::{info, error, debug, warn}; use zmq::{Context, Socket, SocketType}; -use std::time::Duration; use crate::config::ZmqConfig; @@ -80,11 +79,6 @@ impl ZmqConsumer { Ok(()) } - /// Get list of newly connected hosts since last check - pub fn get_newly_connected_hosts(&self) -> Vec { - // For now, return all connected hosts (could be enhanced with state tracking) - self.connected_hosts.iter().cloned().collect() - } /// Receive metrics from any connected agent (non-blocking) pub async fn receive_metrics(&mut self) -> Result> { @@ -128,32 +122,21 @@ impl ZmqConsumer { } } - /// Get list of connected hosts - pub fn get_connected_hosts(&self) -> Vec { - self.connected_hosts.iter().cloned().collect() - } - - /// Check if connected to any hosts - pub fn has_connections(&self) -> bool { - !self.connected_hosts.is_empty() - } } /// ZMQ command sender for sending commands to agents pub struct ZmqCommandSender { context: Context, - config: ZmqConfig, } impl ZmqCommandSender { - pub fn new(config: &ZmqConfig) -> Result { + pub fn new(_config: &ZmqConfig) -> Result { let context = Context::new(); info!("ZMQ command sender initialized"); Ok(Self { context, - config: config.clone(), }) } @@ -181,24 +164,4 @@ impl ZmqCommandSender { // Socket will be automatically closed when dropped Ok(()) } - - /// Send a command to all connected hosts - pub async fn broadcast_command(&self, hosts: &[String], command: AgentCommand) -> Result> { - let mut failed_hosts = Vec::new(); - - for hostname in hosts { - if let Err(e) = self.send_command(hostname, command.clone()).await { - error!("Failed to send command to {}: {}", hostname, e); - failed_hosts.push(hostname.clone()); - } - } - - if failed_hosts.is_empty() { - info!("Successfully broadcast command {:?} to {} hosts", command, hosts.len()); - } else { - warn!("Failed to send command to {} hosts: {:?}", failed_hosts.len(), failed_hosts); - } - - Ok(failed_hosts) - } } \ No newline at end of file diff --git a/dashboard/src/config/mod.rs b/dashboard/src/config/mod.rs index 313613d..594882c 100644 --- a/dashboard/src/config/mod.rs +++ b/dashboard/src/config/mod.rs @@ -111,6 +111,7 @@ impl Default for HostsConfig { "simonbox".to_string(), "steambox".to_string(), "srv01".to_string(), + "srv02".to_string(), ], default_host: Some("cmbox".to_string()), } diff --git a/dashboard/src/metrics/mod.rs b/dashboard/src/metrics/mod.rs index 9cd30cd..3deb9cd 100644 --- a/dashboard/src/metrics/mod.rs +++ b/dashboard/src/metrics/mod.rs @@ -1,13 +1,10 @@ use cm_dashboard_shared::{Metric, Status}; -use std::collections::HashMap; -use std::time::{Duration, Instant}; -use tracing::{debug, info}; +use std::time::Instant; pub mod store; pub mod subscription; pub use store::MetricStore; -pub use subscription::SubscriptionManager; /// Widget types that can subscribe to metrics #[derive(Debug, Clone, Copy, Hash, Eq, PartialEq)] @@ -21,13 +18,6 @@ pub enum WidgetType { Alerts, } -/// Metric subscription entry -#[derive(Debug, Clone)] -pub struct MetricSubscription { - pub widget_type: WidgetType, - pub metric_names: Vec, -} - /// Historical metric data point #[derive(Debug, Clone)] pub struct MetricDataPoint { diff --git a/dashboard/src/metrics/subscription.rs b/dashboard/src/metrics/subscription.rs index 5a85d51..25fee08 100644 --- a/dashboard/src/metrics/subscription.rs +++ b/dashboard/src/metrics/subscription.rs @@ -1,7 +1,7 @@ use std::collections::{HashMap, HashSet}; use tracing::{debug, info}; -use super::{WidgetType, MetricSubscription, subscriptions}; +use super::{WidgetType, subscriptions}; /// Manages metric subscriptions for widgets pub struct SubscriptionManager { @@ -41,23 +41,6 @@ impl SubscriptionManager { subscriptions::MEMORY_WIDGET_METRICS.iter().map(|&s| s.to_string()).collect() ); - // Subscribe Storage widget to storage metrics - self.subscribe_widget( - WidgetType::Storage, - subscriptions::STORAGE_WIDGET_METRICS.iter().map(|&s| s.to_string()).collect() - ); - - // Subscribe Services widget to service metrics - self.subscribe_widget( - WidgetType::Services, - subscriptions::SERVICES_WIDGET_METRICS.iter().map(|&s| s.to_string()).collect() - ); - - // Subscribe Backup widget to backup metrics - self.subscribe_widget( - WidgetType::Backup, - subscriptions::BACKUP_WIDGET_METRICS.iter().map(|&s| s.to_string()).collect() - ); info!("Initialized default widget subscriptions for {} widgets", self.widget_subscriptions.len()); diff --git a/dashboard/src/ui/mod.rs b/dashboard/src/ui/mod.rs index 0ee3553..6ae9273 100644 --- a/dashboard/src/ui/mod.rs +++ b/dashboard/src/ui/mod.rs @@ -330,9 +330,9 @@ impl TuiApp { } // Calculate how many lines we need - let mut total_lines_needed = 0; + let mut _total_lines_needed = 0; for partitions in physical_devices.values() { - total_lines_needed += 2 + partitions.len(); // title + health + usage_per_partition + _total_lines_needed += 2 + partitions.len(); // title + health + usage_per_partition } let available_lines = area.height as usize; diff --git a/dashboard/src/ui/widgets/backup.rs b/dashboard/src/ui/widgets/backup.rs index 10679cb..91a8149 100644 --- a/dashboard/src/ui/widgets/backup.rs +++ b/dashboard/src/ui/widgets/backup.rs @@ -7,7 +7,7 @@ use ratatui::{ use tracing::debug; use super::Widget; -use crate::ui::theme::{Theme, Typography, Components, StatusIcons}; +use crate::ui::theme::{Typography, StatusIcons}; /// Backup widget displaying backup status, services, and repository information #[derive(Clone)] diff --git a/dashboard/src/ui/widgets/cpu.rs b/dashboard/src/ui/widgets/cpu.rs index e77e868..dc9cdf0 100644 --- a/dashboard/src/ui/widgets/cpu.rs +++ b/dashboard/src/ui/widgets/cpu.rs @@ -7,7 +7,7 @@ use ratatui::{ use tracing::debug; use super::Widget; -use crate::ui::theme::{Theme, Typography, Components, StatusIcons}; +use crate::ui::theme::{Typography, StatusIcons}; /// CPU widget displaying load, temperature, and frequency #[derive(Clone)] diff --git a/dashboard/src/ui/widgets/memory.rs b/dashboard/src/ui/widgets/memory.rs index 1030357..b7a70e1 100644 --- a/dashboard/src/ui/widgets/memory.rs +++ b/dashboard/src/ui/widgets/memory.rs @@ -7,7 +7,7 @@ use ratatui::{ use tracing::debug; use super::Widget; -use crate::ui::theme::{Theme, Typography, Components, StatusIcons}; +use crate::ui::theme::{Typography, StatusIcons}; /// Memory widget displaying usage, totals, and swap information #[derive(Clone)] diff --git a/shared/src/metrics.rs b/shared/src/metrics.rs index 9c2f0dd..fee8d5c 100644 --- a/shared/src/metrics.rs +++ b/shared/src/metrics.rs @@ -1,5 +1,5 @@ use serde::{Deserialize, Serialize}; -use chrono::{DateTime, Utc}; +use chrono::Utc; /// Individual metric with value, status, and metadata #[derive(Debug, Clone, Serialize, Deserialize)]