From db0e41a7d3724bb025894e6f23f24b1f7e24ce1f Mon Sep 17 00:00:00 2001 From: Christoffer Martinsson Date: Sat, 15 Nov 2025 11:41:58 +0100 Subject: [PATCH] Remove blocking CollectNow commands to fix heartbeat stability Eliminates automatic CollectNow command sending on host connection which was blocking the main message processing loop for up to 5 seconds per command. Since agents transmit cached data every 2 seconds anyway, the CollectNow optimization provided minimal benefit while causing heartbeat detection issues. Also removes unused send_command wrapper method. This should completely resolve intermittent host connection dropping. --- Cargo.lock | 6 +++--- agent/Cargo.toml | 2 +- dashboard/Cargo.toml | 2 +- dashboard/src/app.rs | 30 ++++-------------------------- shared/Cargo.toml | 2 +- 5 files changed, 10 insertions(+), 32 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 856d124..e7c913b 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -270,7 +270,7 @@ checksum = "a1d728cc89cf3aee9ff92b05e62b19ee65a02b5702cff7d5a377e32c6ae29d8d" [[package]] name = "cm-dashboard" -version = "0.1.69" +version = "0.1.72" dependencies = [ "anyhow", "chrono", @@ -292,7 +292,7 @@ dependencies = [ [[package]] name = "cm-dashboard-agent" -version = "0.1.69" +version = "0.1.72" dependencies = [ "anyhow", "async-trait", @@ -315,7 +315,7 @@ dependencies = [ [[package]] name = "cm-dashboard-shared" -version = "0.1.69" +version = "0.1.72" dependencies = [ "chrono", "serde", diff --git a/agent/Cargo.toml b/agent/Cargo.toml index 097c25b..9f02748 100644 --- a/agent/Cargo.toml +++ b/agent/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "cm-dashboard-agent" -version = "0.1.72" +version = "0.1.73" edition = "2021" [dependencies] diff --git a/dashboard/Cargo.toml b/dashboard/Cargo.toml index 0c851da..f698968 100644 --- a/dashboard/Cargo.toml +++ b/dashboard/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "cm-dashboard" -version = "0.1.72" +version = "0.1.73" edition = "2021" [dependencies] diff --git a/dashboard/src/app.rs b/dashboard/src/app.rs index 893ab07..f803be0 100644 --- a/dashboard/src/app.rs +++ b/dashboard/src/app.rs @@ -134,12 +134,6 @@ impl Dashboard { }) } - /// Send a command to a specific agent - pub async fn send_command(&mut self, hostname: &str, command: AgentCommand) -> Result<()> { - self.zmq_command_sender - .send_command(hostname, command) - .await - } pub async fn run(&mut self) -> Result<()> { info!("Starting dashboard main loop"); @@ -212,34 +206,18 @@ impl Dashboard { metric_message.metrics.len() ); - // Check if this is the first time we've seen this host + // Track first contact with host (no command needed - agent sends data every 2s) let is_new_host = !self .initial_commands_sent .contains(&metric_message.hostname); if is_new_host { info!( - "First contact with host {}, sending initial CollectNow command", + "First contact with host {} - data will update automatically", metric_message.hostname ); - - // Send CollectNow command for immediate refresh - if let Err(e) = self - .send_command(&metric_message.hostname, AgentCommand::CollectNow) - .await - { - error!( - "Failed to send initial CollectNow command to {}: {}", - metric_message.hostname, e - ); - } else { - info!( - "✓ Sent initial CollectNow command to {}", - metric_message.hostname - ); - self.initial_commands_sent - .insert(metric_message.hostname.clone()); - } + self.initial_commands_sent + .insert(metric_message.hostname.clone()); } // Update metric store diff --git a/shared/Cargo.toml b/shared/Cargo.toml index c4e6c0b..1e95f72 100644 --- a/shared/Cargo.toml +++ b/shared/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "cm-dashboard-shared" -version = "0.1.72" +version = "0.1.73" edition = "2021" [dependencies]