added Option to data structs

This commit is contained in:
2025-10-06 12:43:15 +02:00
parent a7cae5e93f
commit 06cec6ff9f
6 changed files with 87 additions and 65 deletions

View File

@@ -4,7 +4,7 @@
//!
use crate::docker::stats;
use crate::docker::stats::{ContainerCpuInfo, ContainerNetworkInfo};
use crate::models::{DockerRegistrationDto, DockerMetricDto, DockerContainer};
use crate::models::DockerContainer;
use bollard::query_parameters::{
CreateImageOptions, ListContainersOptions, RestartContainerOptions,
@@ -178,14 +178,15 @@ pub async fn get_network_stats(
Ok(net_info)
} else {
// Return default network info if not found
println!("No network info found for container {}", container_id);
Ok(ContainerNetworkInfo {
container_id: container_id.to_string(),
rx_bytes: 0,
tx_bytes: 0,
rx_packets: 0,
tx_packets: 0,
rx_errors: 0,
tx_errors: 0,
container_id: Some(container_id.to_string()),
rx_bytes: None,
tx_bytes: None,
rx_packets: None,
tx_packets: None,
rx_errors: None,
tx_errors: None,
})
}
}
@@ -201,12 +202,13 @@ pub async fn get_cpu_stats(
Ok(cpu_info)
} else {
// Return default CPU info if not found
println!("No CPU info found for container {}", container_id);
Ok(ContainerCpuInfo {
container_id: container_id.to_string(),
cpu_usage_percent: 0.0,
system_cpu_usage: 0,
container_cpu_usage: 0,
online_cpus: 1,
container_id: Some(container_id.to_string()),
cpu_usage_percent: None,
system_cpu_usage: None,
container_cpu_usage: None,
online_cpus: None,
})
}
}