Add info-level logging for VPN external IP debugging
All checks were successful
Build and Release / build-and-release (push) Successful in 1m10s

Change debug to info/warn logging to diagnose VPN IP query issues.
Use exact service name match instead of contains.

Version: v0.1.235
This commit is contained in:
Christoffer Martinsson 2025-12-01 14:30:25 +01:00
parent 3fdcec8047
commit 6c6c9144bd
5 changed files with 24 additions and 17 deletions

6
Cargo.lock generated
View File

@ -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",

View File

@ -1,6 +1,6 @@
[package]
name = "cm-dashboard-agent"
version = "0.1.234"
version = "0.1.235"
edition = "2021"
[dependencies]

View File

@ -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
}
}

View File

@ -1,6 +1,6 @@
[package]
name = "cm-dashboard"
version = "0.1.234"
version = "0.1.235"
edition = "2021"
[dependencies]

View File

@ -1,6 +1,6 @@
[package]
name = "cm-dashboard-shared"
version = "0.1.234"
version = "0.1.235"
edition = "2021"
[dependencies]