From 4d8bacef501debcd0a409e21788387693a8fa12c Mon Sep 17 00:00:00 2001 From: Christoffer Martinsson Date: Sun, 12 Oct 2025 20:35:09 +0200 Subject: [PATCH] Testing --- agent/src/collectors/mod.rs | 16 +--------------- agent/src/simple_agent.rs | 9 +++++---- 2 files changed, 6 insertions(+), 19 deletions(-) diff --git a/agent/src/collectors/mod.rs b/agent/src/collectors/mod.rs index 373d564..8834fec 100644 --- a/agent/src/collectors/mod.rs +++ b/agent/src/collectors/mod.rs @@ -10,22 +10,8 @@ pub mod smart; pub use error::CollectorError; -#[derive(Debug, Clone, serde::Serialize)] -pub enum AgentType { - Smart, - Service, - Backup, -} +pub use cm_dashboard_shared::envelope::AgentType; -impl AgentType { - pub fn as_str(&self) -> &'static str { - match self { - AgentType::Smart => "smart", - AgentType::Service => "service", - AgentType::Backup => "backup", - } - } -} #[derive(Debug, Clone)] pub struct CollectorOutput { diff --git a/agent/src/simple_agent.rs b/agent/src/simple_agent.rs index d0949c3..b19ec11 100644 --- a/agent/src/simple_agent.rs +++ b/agent/src/simple_agent.rs @@ -9,8 +9,9 @@ use crate::collectors::{ backup::BackupCollector, service::ServiceCollector, smart::SmartCollector, - Collector, AgentType + Collector }; +use cm_dashboard_shared::envelope::AgentType; use crate::discovery::AutoDiscovery; use crate::notifications::{NotificationManager, NotificationConfig}; @@ -143,10 +144,10 @@ impl SimpleAgent { async fn send_metrics(&self, agent_type: &AgentType, data: &serde_json::Value) -> anyhow::Result<()> { let message = serde_json::json!({ - "host": self.hostname, + "hostname": self.hostname, "agent_type": agent_type, - "data": data, - "timestamp": Utc::now() + "timestamp": Utc::now().timestamp() as u64, + "metrics": data }); let serialized = serde_json::to_string(&message)?;