summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorClement Tsang <34804052+ClementTsang@users.noreply.github.com>2023-02-19 18:44:35 -0500
committerGitHub <noreply@github.com>2023-02-19 18:44:35 -0500
commit6d15f0100901652bd135cab7915c70f79785c047 (patch)
tree8fef45834e935766bcf1ebc637c5851a13b399ff /src
parent2a1c4104fd5c5279b391c02708295839faa351ec (diff)
other: support hw.temperature-based temps on FreeBSD (#1024)
* other: support hw.temperature-based temps for FreeBSD * update changelog * enable sysctl always for freebsd
Diffstat (limited to 'src')
-rw-r--r--src/app/data_harvester/temperature/sysinfo.rs25
1 files changed, 25 insertions, 0 deletions
diff --git a/src/app/data_harvester/temperature/sysinfo.rs b/src/app/data_harvester/temperature/sysinfo.rs
index c1e11527..d72901aa 100644
--- a/src/app/data_harvester/temperature/sysinfo.rs
+++ b/src/app/data_harvester/temperature/sysinfo.rs
@@ -38,5 +38,30 @@ pub fn get_temperature_data(
super::nvidia::add_nvidia_data(&mut temperature_vec, temp_type, filter)?;
}
+ // For RockPro64 boards on FreeBSD, they apparently use "hw.temperature" for sensors.
+ #[cfg(target_os = "freebsd")]
+ {
+ use sysctl::Sysctl;
+
+ const KEY: &str = "hw.temperature";
+ if let Ok(root) = sysctl::Ctl::new(KEY) {
+ for ctl in sysctl::CtlIter::below(root).flatten() {
+ if let (Ok(name), Ok(temp)) = (ctl.name(), ctl.value()) {
+ if let Some(temp) = temp.as_temperature() {
+ temperature_vec.push(TempHarvest {
+ name,
+ temperature: match temp_type {
+ TemperatureType::Celsius => temp.celsius(),
+ TemperatureType::Kelvin => temp.kelvin(),
+ TemperatureType::Fahrenheit => temp.fahrenheit(),
+ },
+ });
+ }
+ }
+ }
+ }
+ }
+
+ // TODO: Should we instead use a hashmap -> vec to skip dupes?
Ok(Some(temperature_vec))
}