Clean up unused imports and fix build warnings

- Remove unused imports (Duration, HashMap, SharedError, DateTime, etc.)
- Fix unused variables by prefixing with underscore
- Remove redundant dashboard.toml config file
- Update theme imports to use only needed components
- Maintain all functionality while reducing warnings
- Add srv02 to predefined hosts configuration
- Remove unused broadcast_command methods
This commit is contained in:
2025-10-18 23:12:07 +02:00
parent f0eec38655
commit 7f85a6436e
21 changed files with 27 additions and 150 deletions

View File

@@ -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 {

View File

@@ -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())

View File

@@ -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

View File

@@ -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};

View File

@@ -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;

View File

@@ -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};

View File

@@ -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;

View File

@@ -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;

View File

@@ -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)

View File

@@ -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;