From 6c6c9144bd3a48b1270158c72f0951f2fe447143 Mon Sep 17 00:00:00 2001 From: Christoffer Martinsson Date: Mon, 1 Dec 2025 14:30:25 +0100 Subject: [PATCH] Add info-level logging for VPN external IP debugging Change debug to info/warn logging to diagnose VPN IP query issues. Use exact service name match instead of contains. Version: v0.1.235 --- Cargo.lock | 6 +++--- agent/Cargo.toml | 2 +- agent/src/collectors/systemd.rs | 29 ++++++++++++++++++----------- dashboard/Cargo.toml | 2 +- shared/Cargo.toml | 2 +- 5 files changed, 24 insertions(+), 17 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 35e0f84..8afcd0b 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -279,7 +279,7 @@ checksum = "a1d728cc89cf3aee9ff92b05e62b19ee65a02b5702cff7d5a377e32c6ae29d8d" [[package]] name = "cm-dashboard" -version = "0.1.234" +version = "0.1.235" dependencies = [ "anyhow", "chrono", @@ -301,7 +301,7 @@ dependencies = [ [[package]] name = "cm-dashboard-agent" -version = "0.1.234" +version = "0.1.235" dependencies = [ "anyhow", "async-trait", @@ -325,7 +325,7 @@ dependencies = [ [[package]] name = "cm-dashboard-shared" -version = "0.1.234" +version = "0.1.235" dependencies = [ "chrono", "serde", diff --git a/agent/Cargo.toml b/agent/Cargo.toml index 9ce43be..218efec 100644 --- a/agent/Cargo.toml +++ b/agent/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "cm-dashboard-agent" -version = "0.1.234" +version = "0.1.235" edition = "2021" [dependencies] diff --git a/agent/src/collectors/systemd.rs b/agent/src/collectors/systemd.rs index ca4565e..bf738e5 100644 --- a/agent/src/collectors/systemd.rs +++ b/agent/src/collectors/systemd.rs @@ -159,16 +159,23 @@ impl SystemdCollector { } } - if service_name.contains("openvpn-vpn-connection") && status_info.active_state == "active" { - if let Some(external_ip) = self.get_vpn_external_ip() { - let metrics = Vec::new(); + if service_name == "openvpn-vpn-connection" && status_info.active_state == "active" { + tracing::info!("Checking VPN external IP for service: {}", service_name); + match self.get_vpn_external_ip() { + Some(external_ip) => { + tracing::info!("Got VPN external IP: {}", external_ip); + let metrics = Vec::new(); - sub_services.push(SubServiceData { - name: format!("IP: {}", external_ip), - service_status: Status::Ok, - metrics, - service_type: "vpn_route".to_string(), - }); + sub_services.push(SubServiceData { + name: format!("IP: {}", external_ip), + service_status: Status::Ok, + metrics, + service_type: "vpn_route".to_string(), + }); + } + None => { + tracing::warn!("Failed to get VPN external IP"); + } } } @@ -872,12 +879,12 @@ impl SystemdCollector { if output.status.success() { let ip = String::from_utf8_lossy(&output.stdout).trim().to_string(); if !ip.is_empty() && ip.contains('.') { - debug!("VPN external IP: {}", ip); return Some(ip); } } - debug!("Failed to get VPN external IP"); + let stderr = String::from_utf8_lossy(&output.stderr); + tracing::warn!("VPN external IP query failed. Exit code: {:?}, stderr: {}", output.status.code(), stderr); None } } diff --git a/dashboard/Cargo.toml b/dashboard/Cargo.toml index 56916e1..480cf33 100644 --- a/dashboard/Cargo.toml +++ b/dashboard/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "cm-dashboard" -version = "0.1.234" +version = "0.1.235" edition = "2021" [dependencies] diff --git a/shared/Cargo.toml b/shared/Cargo.toml index 5162829..216c63c 100644 --- a/shared/Cargo.toml +++ b/shared/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "cm-dashboard-shared" -version = "0.1.234" +version = "0.1.235" edition = "2021" [dependencies]