From 10aa72816d517f1004afa9218b6165cad2622691 Mon Sep 17 00:00:00 2001 From: Christoffer Martinsson Date: Wed, 15 Oct 2025 23:19:44 +0200 Subject: [PATCH] Fix critical ZMQ command loop causing agent failure The handle_commands() function was being called continuously in the main tokio::select! loop, causing thousands of ZMQ state errors that prevented the agent from functioning properly. Temporarily disabled command handling to restore basic functionality. Agent now properly collects and sends metrics without ZMQ errors. Fixes 'No data received' issue on hosts running the new metric-level agent. --- agent/src/smart_agent.rs | 43 ++++------------------------------------ 1 file changed, 4 insertions(+), 39 deletions(-) diff --git a/agent/src/smart_agent.rs b/agent/src/smart_agent.rs index 0c07730..6d90c2f 100644 --- a/agent/src/smart_agent.rs +++ b/agent/src/smart_agent.rs @@ -120,9 +120,6 @@ impl SmartAgent { _ = stats_interval.tick() => { self.log_metric_stats().await; } - _ = self.handle_commands() => { - // Commands handled in background - } } } } @@ -282,42 +279,10 @@ impl SmartAgent { } - /// Handle incoming commands from dashboard (non-blocking) - async fn handle_commands(&mut self) { - // Check for commands with non-blocking receive - match self.zmq_command_socket.recv_string(zmq::DONTWAIT) { - Ok(Ok(command)) => { - info!("Received command: {}", command); - match command.as_str() { - "refresh" => { - info!("Processing refresh command - forcing immediate collection"); - self.force_refresh_all().await; - - // Send response - let response = "refresh_started"; - if let Err(e) = self.zmq_command_socket.send(response, 0) { - warn!("Failed to send command response: {}", e); - } - } - _ => { - warn!("Unknown command: {}", command); - let response = "unknown_command"; - if let Err(e) = self.zmq_command_socket.send(response, 0) { - warn!("Failed to send error response: {}", e); - } - } - } - } - Ok(Err(e)) => { - warn!("String conversion error: {:?}", e); - } - Err(zmq::Error::EAGAIN) => { - // No message available - this is normal - } - Err(e) => { - warn!("ZMQ command receive error: {}", e); - } - } + /// Handle incoming commands from dashboard (temporarily disabled) + async fn _handle_commands(&mut self) { + // TODO: Re-implement command handling properly + // This function was causing ZMQ state errors when called continuously } /// Force immediate collection of all metrics