From df87baa9dd70772c6717124e934db58f1e20281b Mon Sep 17 00:00:00 2001 From: Christoffer Martinsson Date: Thu, 23 Oct 2025 11:56:33 +0200 Subject: [PATCH] Add debug logging to systemd collector to diagnose failure Add detailed debug logging to track where the systemd collector is failing. This will help identify why the collector returns an error during startup. --- agent/src/collectors/systemd.rs | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/agent/src/collectors/systemd.rs b/agent/src/collectors/systemd.rs index e89c1f3..4284ea4 100644 --- a/agent/src/collectors/systemd.rs +++ b/agent/src/collectors/systemd.rs @@ -132,6 +132,7 @@ impl SystemdCollector { /// Auto-discover interesting services to monitor and cache their status fn discover_services(&self) -> Result> { + debug!("Starting systemd service discovery"); let units_output = Command::new("systemctl") .arg("list-units") .arg("--type=service") @@ -213,7 +214,7 @@ impl SystemdCollector { state.service_status_cache = status_cache; } - debug!("Service discovery completed: found {} matching services", services.len()); + debug!("Service discovery completed: found {} matching services: {:?}", services.len(), services); if services.is_empty() { debug!("No services found matching the configured filters - this is a valid state"); } @@ -379,7 +380,10 @@ impl Collector for SystemdCollector { // Get cached services (discovery only happens when needed) let monitored_services = match self.get_monitored_services() { - Ok(services) => services, + Ok(services) => { + debug!("Successfully got {} monitored services", services.len()); + services + }, Err(e) => { debug!("Failed to get monitored services: {}", e); return Ok(metrics);