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.
This commit is contained in:
parent
ce2aeeff34
commit
10aa72816d
@ -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
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user