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

Update sysinfo version #658

Merged
merged 1 commit into from
Jan 20, 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
9 changes: 4 additions & 5 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 @@ -50,7 +50,7 @@ once_cell = "1.5.2"
regex = "1.5.4"
serde = { version = "1.0.125", features = ["derive"] }
# Sysinfo is still used in Linux for the ProcessStatus
sysinfo = "0.18.2"
sysinfo = "0.23.0"
thiserror = "1.0.24"
time = { version = "0.3.5", features = ["formatting", "macros"] }
toml = "0.5.8"
Expand Down
2 changes: 1 addition & 1 deletion src/app/data_harvester.rs
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ impl DataCollector {
#[cfg(not(target_os = "linux"))]
{
self.sys.refresh_memory();
self.mem_total_kb = self.sys.get_total_memory();
self.mem_total_kb = self.sys.total_memory();

// TODO: Would be good to get this and network list running on a timer instead...?
// Refresh components list once...
Expand Down
6 changes: 3 additions & 3 deletions src/app/data_harvester/network/sysinfo.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ pub async fn get_network_data(
let mut total_rx: u64 = 0;
let mut total_tx: u64 = 0;

let networks = sys.get_networks();
let networks = sys.networks();
for (name, network) in networks {
let to_keep = if let Some(filter) = filter {
let mut ret = filter.is_list_ignored;
Expand All @@ -33,8 +33,8 @@ pub async fn get_network_data(
};

if to_keep {
total_rx += network.get_total_received() * 8;
total_tx += network.get_total_transmitted() * 8;
total_rx += network.total_received() * 8;
total_tx += network.total_transmitted() * 8;
}
}

Expand Down
12 changes: 6 additions & 6 deletions src/app/data_harvester/processes/macos.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
//! Process data collection for macOS. Uses sysinfo.

use super::ProcessHarvest;
use sysinfo::{ProcessExt, ProcessStatus, ProcessorExt, System, SystemExt};
use sysinfo::{PidExt, ProcessExt, ProcessStatus, ProcessorExt, System, SystemExt};

fn get_macos_process_cpu_usage(
pids: &[i32],
Expand Down Expand Up @@ -38,9 +38,9 @@ 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.get_processes();
let cpu_usage = sys.get_global_processor_info().get_cpu_usage() as f64 / 100.0;
let num_processors = sys.get_processors().len() as f64;
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;
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 @@ -87,8 +87,8 @@ pub fn get_process_data(

let disk_usage = process_val.disk_usage();
process_vector.push(ProcessHarvest {
pid: process_val.pid(),
parent_pid: process_val.parent(),
pid: process_val.pid().as_u32() as _,
parent_pid: process_val.parent().map(|p| p.as_u32() as _),
name,
command,
mem_usage_percent: if mem_total_kb > 0 {
Expand Down
12 changes: 6 additions & 6 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::{ProcessExt, ProcessorExt, System, SystemExt};
use sysinfo::{PidExt, ProcessExt, ProcessorExt, 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.get_processes();
let cpu_usage = sys.get_global_processor_info().get_cpu_usage() as f64 / 100.0;
let num_processors = sys.get_processors().len() as f64;
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;
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 @@ -56,8 +56,8 @@ pub fn get_process_data(

let disk_usage = process_val.disk_usage();
process_vector.push(ProcessHarvest {
pid: process_val.pid(),
parent_pid: process_val.parent(),
pid: process_val.pid().as_u32() as _,
parent_pid: process_val.parent().map(|p| p.as_u32() as _),
name,
command,
mem_usage_percent: if mem_total_kb > 0 {
Expand Down
12 changes: 5 additions & 7 deletions src/app/data_harvester/temperature/sysinfo.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,20 +22,18 @@ pub async fn get_temperature_data(

let mut temperature_vec: Vec<TempHarvest> = Vec::new();

let sensor_data = sys.get_components();
let sensor_data = sys.components();
for component in sensor_data {
let name = component.get_label().to_string();
let name = component.label().to_string();

if is_temp_filtered(filter, &name) {
temperature_vec.push(TempHarvest {
name,
temperature: match temp_type {
TemperatureType::Celsius => component.get_temperature(),
TemperatureType::Kelvin => {
convert_celsius_to_kelvin(component.get_temperature())
}
TemperatureType::Celsius => component.temperature(),
TemperatureType::Kelvin => convert_celsius_to_kelvin(component.temperature()),
TemperatureType::Fahrenheit => {
convert_celsius_to_fahrenheit(component.get_temperature())
convert_celsius_to_fahrenheit(component.temperature())
}
},
});
Expand Down