diff --git a/WatcherAgent/src/api.rs b/WatcherAgent/src/api.rs index 7374da2..4339cfa 100644 --- a/WatcherAgent/src/api.rs +++ b/WatcherAgent/src/api.rs @@ -5,7 +5,7 @@ use crate::models::{HeartbeatDto, IdResponse, MetricDto, RegistrationDto}; use anyhow::Result; use reqwest::{Client, StatusCode}; use std::error::Error; -use tokio::time::{interval, sleep}; +use tokio::time::sleep; pub async fn register_with_server( base_url: &str, diff --git a/WatcherAgent/src/hardware/mod.rs b/WatcherAgent/src/hardware/mod.rs index 0eba3c2..0b94094 100644 --- a/WatcherAgent/src/hardware/mod.rs +++ b/WatcherAgent/src/hardware/mod.rs @@ -21,7 +21,7 @@ pub struct HardwareInfo { pub memory: memory::MemoryInfo, pub disk: disk::DiskInfo, pub network: network::NetworkInfo, - network_monitor: network::NetworkMonitor, + pub network_monitor: network::NetworkMonitor, } impl HardwareInfo { diff --git a/WatcherAgent/src/hardware/network.rs b/WatcherAgent/src/hardware/network.rs index b90921b..c5bd603 100644 --- a/WatcherAgent/src/hardware/network.rs +++ b/WatcherAgent/src/hardware/network.rs @@ -16,6 +16,12 @@ pub struct NetworkMonitor { last_update: Instant, } +impl Default for NetworkMonitor { + fn default() -> Self { + Self::new() + } +} + impl NetworkMonitor { pub fn new() -> Self { Self { diff --git a/WatcherAgent/src/main.rs b/WatcherAgent/src/main.rs index a990253..fd1fcdc 100644 --- a/WatcherAgent/src/main.rs +++ b/WatcherAgent/src/main.rs @@ -32,7 +32,7 @@ async fn main() -> Result<(), Box> { Ok((id, ip)) => (id, ip), Err(e) => { eprintln!("Fehler bei der Registrierung am Server: {e}"); - return Err(e.into()); + return Err(e); } }; @@ -59,12 +59,11 @@ async fn main() -> Result<(), Box> { let (heartbeat_handle, metrics_handle) = tokio::try_join!(flatten(heartbeat_handle), flatten(metrics_handle))?; - match (heartbeat_handle, metrics_handle) { - (heartbeat, metrics) => println!( - "All tasks completed successfully: {:?}, {:?}.", - heartbeat, metrics - ), - } + let (heartbeat, metrics) = (heartbeat_handle, metrics_handle); + println!( + "All tasks completed successfully: {:?}, {:?}.", + heartbeat, metrics + ); println!("All tasks completed successfully."); diff --git a/WatcherAgent/src/metrics.rs b/WatcherAgent/src/metrics.rs index 5ca541b..381141b 100644 --- a/WatcherAgent/src/metrics.rs +++ b/WatcherAgent/src/metrics.rs @@ -45,7 +45,7 @@ impl Collector { Ok(hw) => hw, Err(e) => { eprintln!("Fehler beim Sammeln der Hardware-Infos: {e}"); - return Err(e.into()); + return Err(e); } }; // Collect network usage