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