Remove all unused code and fix build warnings
- Remove unused struct fields: tier, config_name, last_collection_time - Remove unused structs: PerformanceMetrics, PerfMonitor - Remove unused methods: get_performance_metrics, get_collector_names, get_stats - Remove unused utility functions and system helpers - Remove unused config fields from CPU and Memory collectors - Keep config fields that are actually used (DiskCollector, etc.) - Remove unused proxy_pass_url variable and assignments - Fix duplicate hostname variable declaration - Achieve zero build warnings without functionality changes
This commit is contained in:
@@ -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<super::PerformanceMetrics> {
|
||||
None // Performance tracking handled by cache system
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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<String>, // 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<PerformanceMetrics> {
|
||||
None // Performance tracking handled by cache system
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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<super::PerformanceMetrics> {
|
||||
None // Performance tracking handled by cache system
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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<Vec<Metric>, CollectorError>;
|
||||
|
||||
/// Get performance metrics for monitoring collector efficiency
|
||||
fn get_performance_metrics(&self) -> Option<PerformanceMetrics> {
|
||||
None
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -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<std::time::Duration>,
|
||||
/// Cached state with thread-safe interior mutability
|
||||
state: RwLock<ServiceCacheState>,
|
||||
}
|
||||
@@ -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<PerformanceMetrics> {
|
||||
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<String> {
|
||||
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")) {
|
||||
|
||||
Reference in New Issue
Block a user