Skip to content

Commit

Permalink
feat: remove specific extractors (#261)
Browse files Browse the repository at this point in the history
fix: remove custom extraction code
  • Loading branch information
de-sh authored Jul 27, 2023
1 parent 9623efd commit 71ceb69
Showing 1 changed file with 0 additions and 37 deletions.
37 changes: 0 additions & 37 deletions uplink/src/collector/systemstats.rs
Original file line number Diff line number Diff line change
Expand Up @@ -361,14 +361,6 @@ impl ComponentStats {

comp.into()
}

fn push_custom(&mut self, mut comp_data: Component, timestamp: u64) -> Payload {
self.sequence += 1;
comp_data.timestamp = timestamp;
comp_data.sequence = self.sequence;

(&mut comp_data).into()
}
}

#[derive(Debug, Default, Serialize, Clone)]
Expand Down Expand Up @@ -560,10 +552,6 @@ impl StatCollector {
error!("Error refreshing component statistics: {}", e);
}

if let Err(e) = self.update_special_stats() {
error!("Error refreshing special component statistics: {}", e);
}

if let Err(e) = self.update_process_stats() {
error!("Error refreshing process statistics: {}", e);
}
Expand Down Expand Up @@ -628,31 +616,6 @@ impl StatCollector {
Ok(())
}

// Refresh special component stats
fn update_special_stats(&mut self) -> Result<(), Error> {
let paths = glob::glob("/sys/devices/virtual/thermal/thermal_zone*/temp")?;
let timestamp = clock() as u64;

for path in paths {
let path = match path {
Ok(p) => p,
Err(e) => {
error!("Couldn't extract file path from glob: {e}");
continue;
}
};
let mut label = path.as_os_str().to_str().unwrap_or("temp_component").to_string();
label.retain(|c| c.is_numeric());
let label = "thermal_zone".to_owned() + &label;
let temperature = std::fs::read_to_string(path)?.trim().parse::<f32>()?;
let comp_data = Component { label, temperature, ..Default::default() };
let payload = self.components.push_custom(comp_data, timestamp);
self.bridge_tx.send_payload_sync(payload);
}

Ok(())
}

// Refresh processes info
// NOTE: This can be further optimized by storing pids of interested processes
// at init and only collecting process information for them instead of iterating
Expand Down

0 comments on commit 71ceb69

Please sign in to comment.