Skip to content
This repository was archived by the owner on Nov 15, 2023. It is now read-only.
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
enable process refreshing, ignore result from refresh_process
  • Loading branch information
gnunicorn committed Jul 22, 2020
commit 004e7865d4400e46c902bfdfe251e9abd9ebe2fd
9 changes: 4 additions & 5 deletions client/service/src/metrics.rs
Original file line number Diff line number Diff line change
Expand Up @@ -284,15 +284,14 @@ impl MetricsService {
fn process_info_for(&mut self, pid: &sysinfo::Pid) -> ProcessInfo {
// FIXME: sysinfo::System leaks fd-handlers on Linux. We have to drop it to clean this up
// https://github.com/GuillaumeGomez/sysinfo/issues/352
self.system = sysinfo::System::new();
self.system = sysinfo::System::new_with_specifics(sysinfo::RefreshKind::new().with_processes());

let mut info = ProcessInfo::default();
if self.system.refresh_process(*pid) {
let prc = self.system.get_process(*pid)
.expect("Above refresh_process succeeds, this must be Some(), qed");
self.system.refresh_process(*pid);
self.system.get_process(*pid).map(|prc| {
info.cpu_usage = prc.cpu_usage().into();
info.memory = prc.memory();
}
});
info
}

Expand Down