added another option temp
This commit is contained in:
@@ -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<f32> {
|
||||
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<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
|
||||
}
|
||||
|
||||
/*
|
||||
|
Reference in New Issue
Block a user