Skip to content

Commit

Permalink
fix: troubleshooting host metrics on redhat8
Browse files Browse the repository at this point in the history
  • Loading branch information
bpetit committed Dec 13, 2023
1 parent f85c4eb commit 50bc04d
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions src/sensors/powercap_rapl.rs
Original file line number Diff line number Diff line change
Expand Up @@ -76,25 +76,33 @@ impl RecordReader for Topology {
// else return pkg + dram + F(disks)

if let Some(psys_record) = self.get_rapl_psys_energy_microjoules() {
debug!("Using PSYS metric");
Ok(psys_record)
} else {
let mut total: i128 = 0;
debug!("Suming socket metrics to get host metric");
debug!("Suming socket PKG and DRAM metrics to get host metric");
for s in &self.sockets {
if let Ok(r) = s.read_record() {
match r.value.trim().parse::<i128>() {
Ok(val) => {
total += val;
},
Err(e) => {
debug!("could'nt convert {} to i128: {}", r.value, e);
warn!("could'nt convert {} to i128: {}", r.value.trim(), e);
}
}
}
for d in &s.domains {
if d.name == "dram" {
if let Ok(dr) = d.read_record() {
total = total + dr.value.parse::<i128>().unwrap()
match dr.value.trim().parse::<i128>() {
Ok(val) => {
total += val;
},
Err(e) =>{
warn!("could'nt convert {} to i128: {}", dr.value.trim(), e);
}
}
}
}
}
Expand Down

0 comments on commit 50bc04d

Please sign in to comment.