all functions established; needed to remove orphan functions

This commit is contained in:
2025-08-08 23:28:05 +02:00
parent abfa0b6fc0
commit 93a40fe584
6 changed files with 22 additions and 14 deletions

View File

@@ -2,10 +2,12 @@ use std::error::Error;
use std::time::Duration;
use crate::api;
use crate::hardware::network::NetworkMonitor;
use crate::hardware::HardwareInfo;
use crate::models::MetricDto;
pub struct Collector {
network_monitor: NetworkMonitor,
server_id: i32,
ip_address: String,
}
@@ -13,6 +15,7 @@ pub struct Collector {
impl Collector {
pub fn new(server_id: i32, ip_address: String) -> Self {
Self {
network_monitor: NetworkMonitor::new(),
server_id,
ip_address,
}
@@ -28,6 +31,8 @@ impl Collector {
pub async fn collect(&mut self) -> Result<MetricDto, Box<dyn Error>> {
let hardware = HardwareInfo::collect().await?;
// Collect network usage
let (_, _) = self.network_monitor.update_usage().unwrap_or((0.0, 0.0));
Ok(MetricDto {
server_id: self.server_id,
@@ -43,8 +48,8 @@ impl Collector {
disk_size: hardware.disk.total.unwrap_or_default(),
disk_usage: hardware.disk.used.unwrap_or_default(),
disk_temp: 0.0, // not supported
net_rx: hardware.network.rx_bytes.unwrap_or_default(),
net_tx: hardware.network.tx_bytes.unwrap_or_default(),
net_rx: hardware.network.rx_rate.unwrap_or_default(),
net_tx: hardware.network.tx_rate.unwrap_or_default(),
})
}
}