diff --git a/WatcherAgent/Cargo.toml b/WatcherAgent/Cargo.toml index bb8a9db..e649e4a 100644 --- a/WatcherAgent/Cargo.toml +++ b/WatcherAgent/Cargo.toml @@ -12,11 +12,13 @@ serde_json = "1.0" tokio = { version = "1.37", features = ["full"] } local-ip-address = "0.5" reqwest = { version = "0.11", default-features = false, features = ["json", "blocking", "cookies", "rustls-tls"] } -sysinfo = "0.35" +sysinfo = "0.36.1" +heim = "0.0.11" metrics = "0.24.2" chrono = "0.4" nvml-wrapper = "0.10" + [target.'cfg(windows)'.dependencies] winapi = { version = "0.3", features = ["winuser", "pdh", "ifmib", "iphlpapi", "winerror"] } diff --git a/WatcherAgent/src/main.rs b/WatcherAgent/src/main.rs index 8fa1810..b0b4b34 100644 --- a/WatcherAgent/src/main.rs +++ b/WatcherAgent/src/main.rs @@ -1,4 +1,5 @@ //use chrono::Utc; +use heim::sensors; use nvml_wrapper::Nvml; use reqwest::{Client, StatusCode}; use serde::{Deserialize, Serialize}; @@ -414,7 +415,7 @@ impl MetricsCollector { } fn get_cpu_temp() -> Option { - println!("Attempting to get CPU temperature..."); + /*println!("Attempting to get CPU temperature..."); let components = Components::new_with_refreshed_list(); for component in &components { if let Some(temperature) = component.temperature() { @@ -422,7 +423,25 @@ fn get_cpu_temp() -> Option { } } - Some(0.0) // Placeholder, actual implementation depends on platform + Some(0.0) // Placeholder, actual implementation depends on platform*/ + let mut temperatures = sensors::temperatures(); + while let Some(sensor) = temperatures.next().await { + if let Ok(sensor) = sensor { + if sensor.unit() == heim::units::thermodynamic_temperature::DegreeCelsius { + if let Some(label) = sensor.label() { + if label.contains("CPU") || label.contains("Tdie") || label.contains("Package") + { + return Some( + sensor + .current() + .get::(), + ); + } + } + } + } + } + None } /*