added another option temp

This commit is contained in:
2025-07-31 22:00:19 +02:00
parent e82531e11b
commit 0593bae47a
2 changed files with 24 additions and 3 deletions

View File

@@ -12,11 +12,13 @@ serde_json = "1.0"
tokio = { version = "1.37", features = ["full"] } tokio = { version = "1.37", features = ["full"] }
local-ip-address = "0.5" local-ip-address = "0.5"
reqwest = { version = "0.11", default-features = false, features = ["json", "blocking", "cookies", "rustls-tls"] } 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" metrics = "0.24.2"
chrono = "0.4" chrono = "0.4"
nvml-wrapper = "0.10" nvml-wrapper = "0.10"
[target.'cfg(windows)'.dependencies] [target.'cfg(windows)'.dependencies]
winapi = { version = "0.3", features = ["winuser", "pdh", "ifmib", "iphlpapi", "winerror"] } winapi = { version = "0.3", features = ["winuser", "pdh", "ifmib", "iphlpapi", "winerror"] }

View File

@@ -1,4 +1,5 @@
//use chrono::Utc; //use chrono::Utc;
use heim::sensors;
use nvml_wrapper::Nvml; use nvml_wrapper::Nvml;
use reqwest::{Client, StatusCode}; use reqwest::{Client, StatusCode};
use serde::{Deserialize, Serialize}; use serde::{Deserialize, Serialize};
@@ -414,7 +415,7 @@ impl MetricsCollector {
} }
fn get_cpu_temp() -> Option<f32> { fn get_cpu_temp() -> Option<f32> {
println!("Attempting to get CPU temperature..."); /*println!("Attempting to get CPU temperature...");
let components = Components::new_with_refreshed_list(); let components = Components::new_with_refreshed_list();
for component in &components { for component in &components {
if let Some(temperature) = component.temperature() { if let Some(temperature) = component.temperature() {
@@ -422,7 +423,25 @@ fn get_cpu_temp() -> Option<f32> {
} }
} }
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::<heim::units::thermodynamic_temperature::degree_celsius>(),
);
}
}
}
}
}
None
} }
/* /*