diff --git a/proto/agent.proto b/proto/agent.proto index 8590b52..d84d479 100644 --- a/proto/agent.proto +++ b/proto/agent.proto @@ -162,6 +162,7 @@ message SnmpResult { JobType job_type = 2; map oid_values = 3; int64 timestamp = 4; + string job_id = 5; } message AgentHeartbeat { diff --git a/src/api_client.rs b/src/api_client.rs index 5170749..b419285 100644 --- a/src/api_client.rs +++ b/src/api_client.rs @@ -2,9 +2,9 @@ use crate::config::{AgentConfig, HeartbeatMetadata}; use crate::metrics::Metric; use crate::proto::agent; use prost::Message; -use serde_json::json; use std::time::Duration; use thiserror::Error; +use tracing::debug; #[derive(Debug, Error)] pub enum ApiError { @@ -49,15 +49,19 @@ impl ApiClient { .map_err(|e| ApiError::RequestFailed(e.to_string()))?; let status = response.status(); + debug!("fetch_config response: status={}", status); + if status != 200 { return Err(ApiError::StatusError(status)); } - let config: AgentConfig = response - .into_json() + let body = response + .into_string() .map_err(|e| ApiError::RequestFailed(e.to_string()))?; + debug!("fetch_config response body: {}", body); - Ok(config) + let config: AgentConfig = serde_json::from_str(&body) + .map_err(|e| ApiError::RequestFailed(e.to_string()))?; }) .await .map_err(|e| ApiError::JoinError(e.to_string()))??; @@ -100,10 +104,17 @@ impl ApiClient { .map_err(|e| ApiError::RequestFailed(e.to_string()))?; let status = response.status(); + debug!("submit_metrics response: status={}", status); + if status != 200 { return Err(ApiError::StatusError(status)); } + let body = response + .into_string() + .map_err(|e| ApiError::RequestFailed(e.to_string()))?; + debug!("submit_metrics response body: {}", body); + Ok(()) }) .await @@ -125,10 +136,17 @@ impl ApiClient { .map_err(|e| ApiError::RequestFailed(e.to_string()))?; let status = response.status(); + debug!("heartbeat response: status={}", status); + if status != 200 { return Err(ApiError::StatusError(status)); } + let body = response + .into_string() + .map_err(|e| ApiError::RequestFailed(e.to_string()))?; + debug!("heartbeat response body: {}", body); + Ok(()) }) .await diff --git a/src/snmp/client.rs b/src/snmp/client.rs index dd31ef1..cea85b8 100644 --- a/src/snmp/client.rs +++ b/src/snmp/client.rs @@ -3,10 +3,10 @@ use crate::secret::SecretString; use snmp2::SyncSession; use std::time::Duration; -// SNMP timeout in seconds - increased to 90s for SNMPv3 operations +// SNMP timeout in seconds - increased to 120s for SNMPv3 operations // SNMPv3 has significant encryption/auth overhead, especially for large walks // Full discovery can take 50+ seconds with complete MikroTik OID tree traversal -const SNMP_TIMEOUT_SECS: u64 = 90; +const SNMP_TIMEOUT_SECS: u64 = 120; /// SNMPv3 configuration bundle #[derive(Clone)] diff --git a/src/snmp/device_poller.rs b/src/snmp/device_poller.rs index 1654d9d..5ded3f2 100644 --- a/src/snmp/device_poller.rs +++ b/src/snmp/device_poller.rs @@ -6,10 +6,10 @@ use std::str::FromStr; use std::time::Duration; use tokio::sync::{mpsc, oneshot}; -// SNMP timeout in seconds - increased to 90s for SNMPv3 operations +// SNMP timeout in seconds - increased to 120s for SNMPv3 operations // SNMPv3 has significant encryption/auth overhead // Full discovery can take 50+ seconds with complete MikroTik OID tree traversal -const SNMP_TIMEOUT_SECS: u64 = 90; +const SNMP_TIMEOUT_SECS: u64 = 120; /// Request to perform an SNMP operation #[derive(Debug)] diff --git a/src/websocket_client.rs b/src/websocket_client.rs index 7ea5b65..a1182fe 100644 --- a/src/websocket_client.rs +++ b/src/websocket_client.rs @@ -647,8 +647,9 @@ async fn execute_snmp_job( // Build result let result = SnmpResult { - device_id: job.device_id, + device_id: job.device_id.clone(), job_type: job.job_type, + job_id: job.job_id.clone(), oid_values, timestamp: std::time::SystemTime::now() .duration_since(std::time::UNIX_EPOCH)?