Compare commits

..

1 Commits

Author SHA1 Message Date
5d37f08075 moved serde name to camleCase
All checks were successful
Rust Cross-Platform Build / Detect Rust Project (push) Successful in 4s
Rust Cross-Platform Build / Run Tests (push) Successful in 1m6s
Rust Cross-Platform Build / Build (x86_64-unknown-linux-gnu) (push) Successful in 2m49s
Rust Cross-Platform Build / Build (x86_64-pc-windows-gnu) (push) Successful in 3m35s
Rust Cross-Platform Build / Set Tag Name (push) Successful in 4s
Rust Cross-Platform Build / Build and Push Docker Image (push) Successful in 2m2s
Rust Cross-Platform Build / Workflow Summary (push) Successful in 1s
Rust Cross-Platform Build / Create Tag (push) Successful in 4s
2025-11-02 18:47:01 +01:00
3 changed files with 31 additions and 33 deletions

View File

@@ -207,16 +207,12 @@ pub async fn broadcast_docker_containers(
loop { loop {
println!("Attempting to broadcast containers..."); println!("Attempting to broadcast containers...");
let json_body = serde_json::to_string_pretty(&broadcast_data)?; println!("📤 Docker-Services-json being posted:\n{}", serde_json::to_string_pretty(&broadcast_data)?);
println!("📤 JSON being posted:\n{}", json_body);
let url = format!("{}/monitoring/service-discovery", base_url); let url = format!("{}/monitoring/service-discovery", base_url);
match client.post(&url).json(&container_dto).send().await { match client.post(&url).json(&container_dto).send().await {
Ok(resp) if resp.status().is_success() => { Ok(resp) if resp.status().is_success() => {
println!( println!("✅ Successfully broadcasted docker services");
"✅ Successfully broadcasted following docker container: {:?}",
container_dto
);
return Ok(()); return Ok(());
} }
Ok(resp) => { Ok(resp) => {
@@ -284,7 +280,7 @@ pub async fn send_metrics(
) -> Result<(), Box<dyn Error + Send + Sync>> { ) -> Result<(), Box<dyn Error + Send + Sync>> {
let client = Client::new(); let client = Client::new();
let url = format!("{}/monitoring/metric", base_url); let url = format!("{}/monitoring/metric", base_url);
println!("Metrics: {:?}", metrics); println!("📤 System-Metrics-json being posted:\n{}", serde_json::to_string_pretty(&metrics)?);
match client.post(&url).json(&metrics).send().await { match client.post(&url).json(&metrics).send().await {
Ok(res) => println!( Ok(res) => println!(
@@ -454,7 +450,7 @@ pub async fn send_docker_metrics(
let client = Client::new(); let client = Client::new();
let url = format!("{}/monitoring/docker-metric", base_url); let url = format!("{}/monitoring/docker-metric", base_url);
println!("📤 JSON being posted:\n{}", serde_json::to_string_pretty(&docker_metrics)?); println!("📤 Docker-Metrics-json being posted:\n{}", serde_json::to_string_pretty(&docker_metrics)?);
match client.post(&url).json(&docker_metrics).send().await { match client.post(&url).json(&docker_metrics).send().await {
Ok(res) => println!( Ok(res) => println!(

View File

@@ -219,15 +219,6 @@ impl DockerManager {
} }
}; };
println!(
"Debug: Found {} containers, {} CPU stats, {} network stats, {} memory stats, {} status stats",
containers.len(),
cpu_stats.len(),
net_stats.len(),
mem_stats.len(),
status_stats.len(),
);
let container_infos_total: Vec<_> = containers let container_infos_total: Vec<_> = containers
.into_iter() .into_iter()
.map(|container| { .map(|container| {

View File

@@ -63,31 +63,31 @@ pub struct MetricDto {
pub server_id: u16, pub server_id: u16,
#[serde(rename = "ipAddress")] #[serde(rename = "ipAddress")]
pub ip_address: String, pub ip_address: String,
#[serde(rename = "cpu_Load")] #[serde(rename = "cpuLoad")]
pub cpu_load: f64, pub cpu_load: f64,
#[serde(rename = "cpu_Temp")] #[serde(rename = "cpuTemp")]
pub cpu_temp: f64, pub cpu_temp: f64,
#[serde(rename = "gpu_Load")] #[serde(rename = "gpuLoad")]
pub gpu_load: f64, pub gpu_load: f64,
#[serde(rename = "gpu_Temp")] #[serde(rename = "gpuTemp")]
pub gpu_temp: f64, pub gpu_temp: f64,
#[serde(rename = "gpu_Vram_Size")] #[serde(rename = "gpuVramSize")]
pub gpu_vram_size: f64, pub gpu_vram_size: f64,
#[serde(rename = "gpu_Vram_Load")] #[serde(rename = "gpuVramLoad")]
pub gpu_vram_load: f64, pub gpu_vram_load: f64,
#[serde(rename = "ram_Load")] #[serde(rename = "ramLoad")]
pub ram_load: f64, pub ram_load: f64,
#[serde(rename = "ram_Size")] #[serde(rename = "ramSize")]
pub ram_size: f64, pub ram_size: f64,
#[serde(rename = "disk_Size")] #[serde(rename = "diskSize")]
pub disk_size: f64, pub disk_size: f64,
#[serde(rename = "disk_Usage")] #[serde(rename = "diskUsage")]
pub disk_usage: f64, pub disk_usage: f64,
#[serde(rename = "disk_Temp")] #[serde(rename = "diskTemp")]
pub disk_temp: f64, pub disk_temp: f64,
#[serde(rename = "net_In")] #[serde(rename = "netIn")]
pub net_rx: f64, pub net_rx: f64,
#[serde(rename = "net_Out")] #[serde(rename = "netOut")]
pub net_tx: f64, pub net_tx: f64,
} }
@@ -128,7 +128,7 @@ pub struct IdResponse {
/// - `ip_address`: IPv4 or IPv6 address (string) /// - `ip_address`: IPv4 or IPv6 address (string)
#[derive(Serialize)] #[derive(Serialize)]
pub struct HeartbeatDto { pub struct HeartbeatDto {
#[serde(rename = "IpAddress")] #[serde(rename = "ipAddress")]
pub ip_address: String, pub ip_address: String,
} }
@@ -142,10 +142,15 @@ pub struct HeartbeatDto {
/// - `ip_address`: IPv4 or IPv6 address (string) /// - `ip_address`: IPv4 or IPv6 address (string)
#[derive(Serialize, Debug)] #[derive(Serialize, Debug)]
pub struct HardwareDto { pub struct HardwareDto {
#[serde(rename = "cpuType")]
pub cpu_type: String, pub cpu_type: String,
#[serde(rename = "cpuCore")]
pub cpu_cores: i32, pub cpu_cores: i32,
#[serde(rename = "gpuType")]
pub gpu_type: String, pub gpu_type: String,
#[serde(rename = "ramSize")]
pub ram_size: f64, pub ram_size: f64,
#[serde(rename = "ipAddress")]
pub ip_address: String, pub ip_address: String,
} }
@@ -186,7 +191,7 @@ pub struct Acknowledgment {
#[derive(Debug, Serialize, Clone)] #[derive(Debug, Serialize, Clone)]
pub struct DockerServiceDto { pub struct DockerServiceDto {
/// Unique server identifier (integer) /// Unique server identifier (integer)
#[serde(rename = "Server_id")] #[serde(rename = "serverId")]
pub server_id: u16, pub server_id: u16,
/// Number of currently running containers /// Number of currently running containers
// pub container_count: usize, --- IGNORE --- // pub container_count: usize, --- IGNORE ---
@@ -199,12 +204,13 @@ pub struct DockerServiceDto {
/// id: unique container ID (first 12 hex digits) /// id: unique container ID (first 12 hex digits)
/// image: docker image name /// image: docker image name
/// name: container name /// name: container name
#[serde(rename = "Containers")] #[serde(rename = "containers")]
pub containers: Value, // Vec<DockerContainer>, pub containers: Value, // Vec<DockerContainer>,
} }
#[derive(Debug, Serialize, Clone)] #[derive(Debug, Serialize, Clone)]
pub struct DockerMetricDto { pub struct DockerMetricDto {
#[serde(rename = "serverId")]
pub server_id: u16, pub server_id: u16,
/// json stringified array of DockerContainer /// json stringified array of DockerContainer
/// ///
@@ -219,6 +225,7 @@ pub struct DockerMetricDto {
/// network: network stats /// network: network stats
/// cpu: cpu stats /// cpu: cpu stats
/// ram: ram stats /// ram: ram stats
#[serde(rename = "containers")]
pub containers: Value, // Vec<DockerContainerInfo>, pub containers: Value, // Vec<DockerContainerInfo>,
} }
@@ -239,18 +246,22 @@ pub struct DockerContainerStatusDto {
#[derive(Debug, Serialize, Clone)] #[derive(Debug, Serialize, Clone)]
pub struct DockerContainerCpuDto { pub struct DockerContainerCpuDto {
#[serde(rename = "cpuLoad")]
pub cpu_load: Option<f64>, pub cpu_load: Option<f64>,
} }
#[derive(Debug, Serialize, Clone)] #[derive(Debug, Serialize, Clone)]
pub struct DockerContainerRamDto { pub struct DockerContainerRamDto {
#[serde(rename = "ramLoad")]
pub ram_load: Option<f64>, pub ram_load: Option<f64>,
} }
#[derive(Debug, Serialize, Clone)] #[derive(Debug, Serialize, Clone)]
pub struct DockerContainerNetworkDto { pub struct DockerContainerNetworkDto {
#[serde(rename = "netIn")]
pub net_in: Option<f64>, pub net_in: Option<f64>,
#[serde(rename = "netOut")]
pub net_out: Option<f64>, pub net_out: Option<f64>,
} }