Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

deps: update sysinfo to 0.26.2 #806

Merged
merged 3 commits into from
Sep 16, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
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
4 changes: 2 additions & 2 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ once_cell = "1.5.2"
regex = "1.5.5"
serde = { version = "1.0.136", features = ["derive"] }
starship-battery = { version = "0.7.9", optional = true }
sysinfo = "0.23.10"
sysinfo = "0.26.2"
thiserror = "1.0.30"
time = { version = "0.3.9", features = ["formatting", "macros"] }
toml = "0.5.9"
Expand Down
2 changes: 1 addition & 1 deletion docs/content/support/unofficial.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,4 @@ Unofficially supported platforms known to compile/work:

## Known problems

- ARM-based macOS devices currently doesn't support the temperature widget. This should hopefully be fixed soon.
None at the moment.
4 changes: 2 additions & 2 deletions src/app/data_harvester/cpu/sysinfo.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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(),
Expand Down
2 changes: 1 addition & 1 deletion src/app/data_harvester/processes.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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")]
Expand Down
2 changes: 1 addition & 1 deletion src/app/data_harvester/processes/linux.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
20 changes: 12 additions & 8 deletions src/app/data_harvester/processes/macos_freebsd.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand All @@ -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();
Expand Down Expand Up @@ -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 _),
Expand All @@ -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()),
});
}

Expand Down
6 changes: 3 additions & 3 deletions src/app/data_harvester/processes/windows.rs
Original file line number Diff line number Diff line change
@@ -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();
Expand Down