mirror of
https://codeberg.org/icewind/palantir.git
synced 2026-06-03 18:24:08 +02:00
amdgpu temp
This commit is contained in:
parent
3af0288836
commit
56ccc821fb
2 changed files with 14 additions and 10 deletions
|
|
@ -102,6 +102,7 @@ pub fn get_metrics() -> Result<String> {
|
|||
}
|
||||
}
|
||||
for (label, temp) in temperatures {
|
||||
if temp != 0.0 {
|
||||
writeln!(
|
||||
&mut result,
|
||||
"temperature{{host=\"{}\", sensor=\"{}\"}} {:.1}",
|
||||
|
|
@ -109,5 +110,6 @@ pub fn get_metrics() -> Result<String> {
|
|||
)
|
||||
.ok();
|
||||
}
|
||||
}
|
||||
Ok(result)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -14,14 +14,15 @@ use std::os::unix::ffi::OsStrExt;
|
|||
#[derive(Debug, Clone, Default)]
|
||||
pub struct Temperatures {
|
||||
cpu: f32,
|
||||
gpu: f32,
|
||||
}
|
||||
|
||||
impl IntoIterator for Temperatures {
|
||||
type Item = (&'static str, f32);
|
||||
type IntoIter = IntoIter<Self::Item, 1>;
|
||||
type IntoIter = IntoIter<Self::Item, 2>;
|
||||
|
||||
fn into_iter(self) -> Self::IntoIter {
|
||||
IntoIter::new([("cpu", self.cpu)])
|
||||
IntoIter::new([("cpu", self.cpu), ("gpu", self.gpu)])
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -49,8 +50,8 @@ pub struct DiskUsage {
|
|||
pub fn temperatures() -> Result<Temperatures> {
|
||||
let mut temps = Temperatures::default();
|
||||
|
||||
const DESIRED_HW_MON: &[&[u8]] = &[b"k10temp\n", b"coretemp\n"];
|
||||
const DESIRED_SENSORS: &[&[u8]] = &[b"Tdie\n"];
|
||||
const DESIRED_HW_MON: &[&[u8]] = &[b"k10temp\n", b"coretemp\n", b"amdgpu\n"];
|
||||
const DESIRED_SENSORS: &[&[u8]] = &[b"Tdie\n", b"edge\n"];
|
||||
|
||||
let mut cores_found = 0.0;
|
||||
let mut core_total = 0.0;
|
||||
|
|
@ -84,6 +85,7 @@ pub fn temperatures() -> Result<Temperatures> {
|
|||
let parsed: u32 = value.trim().parse()?;
|
||||
match (hwmon_name.as_slice(), label.as_slice()) {
|
||||
(b"k10temp\n", b"Tdie\n") => temps.cpu = parsed as f32 / 1000.0,
|
||||
(b"amdgpu\n", b"edge\n") => temps.gpu = parsed as f32 / 1000.0,
|
||||
(b"coretemp\n", core) if core.starts_with(b"Core") => {
|
||||
cores_found += 1.0;
|
||||
core_total += parsed as f32 / 1000.0
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue