trying different stöff
This commit is contained in:
@@ -242,7 +242,7 @@ pub async fn get_cpu_temp() -> Result<f64, Box<dyn Error>> {
|
||||
(*services).Release();
|
||||
(*locator).Release();
|
||||
|
||||
return Ok(result.unwrap() as f64).map_err(|e| e.into());
|
||||
Ok(result.unwrap() as f64).map_err(|e| e.into())
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -132,11 +132,7 @@ pub fn get_disk_utitlization() -> Result<(f64, f64, f64, f64), Box<dyn Error>> {
|
||||
}
|
||||
|
||||
pub fn _get_disk_temp_for_component(component: &Component) -> Option<f64> {
|
||||
if let Some(temp) = component.temperature() {
|
||||
Some(temp as f64)
|
||||
} else {
|
||||
None
|
||||
}
|
||||
component.temperature().map(|temp| temp as f64)
|
||||
}
|
||||
|
||||
pub fn _get_disk_load_for_disk(disk: &Disk) -> Result<(f64, f64, f64, f64), Box<dyn Error>> {
|
||||
|
@@ -21,8 +21,8 @@ pub async fn get_gpu_info() -> Result<GpuInfo, Box<dyn Error>> {
|
||||
name: Some(gpu_name),
|
||||
current_load: get_gpu_load(&device).ok(),
|
||||
current_temp: get_gpu_temp(&device).ok(),
|
||||
vram_total: Some(total as f64),
|
||||
vram_used: Some(used as f64),
|
||||
vram_total: Some(total),
|
||||
vram_used: Some(used),
|
||||
})
|
||||
}
|
||||
|
||||
@@ -72,7 +72,7 @@ fn fallback_gpu_name() -> Option<String> {
|
||||
#[cfg(target_os = "windows")]
|
||||
{
|
||||
let output = std::process::Command::new("wmic")
|
||||
.args(&["path", "win32_VideoController", "get", "name"])
|
||||
.args(["path", "win32_VideoController", "get", "name"])
|
||||
.output()
|
||||
.ok()?;
|
||||
Some(
|
||||
|
@@ -1,11 +1,11 @@
|
||||
//use anyhow::Result;
|
||||
use std::error::Error;
|
||||
|
||||
pub(crate) mod cpu;
|
||||
pub(crate) mod disk;
|
||||
pub mod cpu;
|
||||
pub mod disk;
|
||||
pub mod gpu;
|
||||
pub(crate) mod memory;
|
||||
pub(crate) mod network;
|
||||
pub mod memory;
|
||||
pub mod network;
|
||||
|
||||
pub use cpu::get_cpu_info;
|
||||
pub use disk::get_disk_info;
|
||||
|
@@ -53,8 +53,8 @@ pub async fn get_network_info(monitor: &mut NetworkMonitor) -> Result<NetworkInf
|
||||
let (rx_rate, tx_rate) = monitor.update_usage()?;
|
||||
Ok(NetworkInfo {
|
||||
interfaces: Some(get_network_interfaces()),
|
||||
rx_rate: Some(rx_rate as f64),
|
||||
tx_rate: Some(tx_rate as f64),
|
||||
rx_rate: Some(rx_rate),
|
||||
tx_rate: Some(tx_rate),
|
||||
})
|
||||
}
|
||||
|
||||
@@ -96,7 +96,7 @@ fn get_network_bytes() -> Result<(u64, u64), Box<dyn Error>> {
|
||||
}
|
||||
|
||||
if rx_total == 0 && tx_total == 0 {
|
||||
return Err(anyhow::anyhow!("No network data available").into());
|
||||
Err(anyhow::anyhow!("No network data available").into())
|
||||
} else {
|
||||
Ok((rx_total, tx_total))
|
||||
}
|
||||
|
@@ -1,12 +1,12 @@
|
||||
/// WatcherAgent - A Rust-based system monitoring agent
|
||||
/// This agent collects hardware metrics and sends them to a backend server.
|
||||
/// It supports CPU, GPU, RAM, disk, and network metrics.
|
||||
mod api;
|
||||
mod hardware;
|
||||
mod metrics;
|
||||
mod models;
|
||||
pub mod api;
|
||||
pub mod hardware;
|
||||
pub mod metrics;
|
||||
pub mod models;
|
||||
|
||||
use crate::hardware::gpu;
|
||||
pub use crate::hardware::gpu;
|
||||
use anyhow::Result;
|
||||
use std::error::Error;
|
||||
|
||||
|
Reference in New Issue
Block a user