diff options
author | Clement Tsang <34804052+ClementTsang@users.noreply.github.com> | 2022-09-16 04:42:24 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-09-16 04:42:24 -0400 |
commit | c6c7fb3a30f00f4f5025fdb487b513c723335694 (patch) | |
tree | de2cca1f4a8d1d98f3481197ae63d4fd4cf6cb5f /src | |
parent | a427a9d2f2f90d651b046ea439d4626935372b89 (diff) |
deps: update sysinfo to 0.26.2 (#806)
* deps: update sysinfo to 0.26.2
This dependency update has some nice things in store for us:
- MacOS M1 temperature support
- Bevy of bug fixes
* update documentation
* some fixes
Diffstat (limited to 'src')
-rw-r--r-- | src/app/data_harvester/cpu/sysinfo.rs | 4 | ||||
-rw-r--r-- | src/app/data_harvester/processes.rs | 2 | ||||
-rw-r--r-- | src/app/data_harvester/processes/linux.rs | 2 | ||||
-rw-r--r-- | src/app/data_harvester/processes/macos_freebsd.rs | 20 | ||||
-rw-r--r-- | src/app/data_harvester/processes/windows.rs | 6 |
5 files changed, 19 insertions, 15 deletions
diff --git a/src/app/data_harvester/cpu/sysinfo.rs b/src/app/data_harvester/cpu/sysinfo.rs index 864161d4..a5f363b8 100644 --- a/src/app/data_harvester/cpu/sysinfo.rs +++ b/src/app/data_harvester/cpu/sysinfo.rs @@ -3,7 +3,7 @@ use std::collections::VecDeque; -use sysinfo::{LoadAvg, ProcessorExt, System, SystemExt}; +use sysinfo::{LoadAvg, System, SystemExt}; use super::{CpuData, CpuHarvest, PastCpuTotal, PastCpuWork}; use crate::app::data_harvester::cpu::LoadAvgHarvest; @@ -25,7 +25,7 @@ pub async fn get_cpu_data_list( .collect(); if show_average_cpu { - let cpu = sys.global_processor_info(); + let cpu = sys.global_cpu_info(); cpu_deque.push_front(CpuData { cpu_prefix: "AVG".to_string(), diff --git a/src/app/data_harvester/processes.rs b/src/app/data_harvester/processes.rs index 347b46c1..96b1fbda 100644 --- a/src/app/data_harvester/processes.rs +++ b/src/app/data_harvester/processes.rs @@ -70,7 +70,7 @@ pub struct ProcessHarvest { /// This is the *effective* user ID of the process. This is only used on Unix platforms. #[cfg(target_family = "unix")] - pub uid: libc::uid_t, + pub uid: Option<libc::uid_t>, /// This is the process' user. This is only used on Unix platforms. #[cfg(target_family = "unix")] diff --git a/src/app/data_harvester/processes/linux.rs b/src/app/data_harvester/processes/linux.rs index 1e91f93a..99412247 100644 --- a/src/app/data_harvester/processes/linux.rs +++ b/src/app/data_harvester/processes/linux.rs @@ -219,7 +219,7 @@ fn read_proc( total_read_bytes, total_write_bytes, process_state, - uid, + uid: Some(uid), user: user_table .get_uid_to_username_mapping(uid) .map(Into::into) diff --git a/src/app/data_harvester/processes/macos_freebsd.rs b/src/app/data_harvester/processes/macos_freebsd.rs index c50bc74d..cff6dab1 100644 --- a/src/app/data_harvester/processes/macos_freebsd.rs +++ b/src/app/data_harvester/processes/macos_freebsd.rs @@ -4,7 +4,7 @@ use std::collections::HashMap; use std::io; use super::ProcessHarvest; -use sysinfo::{PidExt, ProcessExt, ProcessStatus, ProcessorExt, System, SystemExt}; +use sysinfo::{CpuExt, PidExt, ProcessExt, ProcessStatus, System, SystemExt}; use crate::data_harvester::processes::UserTable; @@ -14,8 +14,8 @@ pub fn get_process_data( ) -> crate::utils::error::Result<Vec<ProcessHarvest>> { let mut process_vector: Vec<ProcessHarvest> = Vec::new(); let process_hashmap = sys.processes(); - let cpu_usage = sys.global_processor_info().cpu_usage() as f64 / 100.0; - let num_processors = sys.processors().len() as f64; + let cpu_usage = sys.global_cpu_info().cpu_usage() as f64 / 100.0; + let num_processors = sys.cpus().len() as f64; for process_val in process_hashmap.values() { let name = if process_val.name().is_empty() { let process_cmd = process_val.cmd(); @@ -65,7 +65,7 @@ pub fn get_process_data( let ps = process_val.status(); (ps.to_string(), convert_process_status_to_char(ps)) }; - let uid = process_val.uid; + let uid = process_val.user_id().map(|u| **u); process_vector.push(ProcessHarvest { pid: process_val.pid().as_u32() as _, parent_pid: process_val.parent().map(|p| p.as_u32() as _), @@ -84,10 +84,14 @@ pub fn get_process_data( total_write_bytes: disk_usage.total_written_bytes, process_state, uid, - user: user_table - .get_uid_to_username_mapping(uid) - .map(Into::into) - .unwrap_or_else(|_| "N/A".into()), + user: uid + .and_then(|uid| { + user_table + .get_uid_to_username_mapping(uid) + .map(Into::into) + .ok() + }) + .unwrap_or_else(|| "N/A".into()), }); } diff --git a/src/app/data_harvester/processes/windows.rs b/src/app/data_harvester/processes/windows.rs index a3564874..36907b11 100644 --- a/src/app/data_harvester/processes/windows.rs +++ b/src/app/data_harvester/processes/windows.rs @@ -1,15 +1,15 @@ //! Process data collection for Windows. Uses sysinfo. use super::ProcessHarvest; -use sysinfo::{PidExt, ProcessExt, ProcessorExt, System, SystemExt}; +use sysinfo::{CpuExt, PidExt, ProcessExt, System, SystemExt}; pub fn get_process_data( sys: &System, use_current_cpu_total: bool, mem_total_kb: u64, ) -> crate::utils::error::Result<Vec<ProcessHarvest>> { let mut process_vector: Vec<ProcessHarvest> = Vec::new(); let process_hashmap = sys.processes(); - let cpu_usage = sys.global_processor_info().cpu_usage() as f64 / 100.0; - let num_processors = sys.processors().len() as f64; + let cpu_usage = sys.global_cpu_info().cpu_usage() as f64 / 100.0; + let num_processors = sys.cpus().len() as f64; for process_val in process_hashmap.values() { let name = if process_val.name().is_empty() { let process_cmd = process_val.cmd(); |