diff options
author | Guillaume Gomez <guillaume.gomez@huawei.com> | 2022-01-18 11:47:31 +0100 |
---|---|---|
committer | Guillaume Gomez <guillaume.gomez@huawei.com> | 2022-01-20 13:00:15 +0100 |
commit | e195b056b065f23e3840ad547b88512e863d0964 (patch) | |
tree | 60e871ebaf3a7380d84025f66e75b99d20cd460b /src | |
parent | 398d52af2e6b001256adef71be8e7c85a943066c (diff) |
Update sysinfo version
Diffstat (limited to 'src')
-rw-r--r-- | src/app/data_harvester.rs | 2 | ||||
-rw-r--r-- | src/app/data_harvester/network/sysinfo.rs | 6 | ||||
-rw-r--r-- | src/app/data_harvester/processes/macos.rs | 12 | ||||
-rw-r--r-- | src/app/data_harvester/processes/windows.rs | 12 | ||||
-rw-r--r-- | src/app/data_harvester/temperature/sysinfo.rs | 12 |
5 files changed, 21 insertions, 23 deletions
diff --git a/src/app/data_harvester.rs b/src/app/data_harvester.rs index 79427a9f..59e01237 100644 --- a/src/app/data_harvester.rs +++ b/src/app/data_harvester.rs @@ -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... diff --git a/src/app/data_harvester/network/sysinfo.rs b/src/app/data_harvester/network/sysinfo.rs index cb8e260a..634cf779 100644 --- a/src/app/data_harvester/network/sysinfo.rs +++ b/src/app/data_harvester/network/sysinfo.rs @@ -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; @@ -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; } } diff --git a/src/app/data_harvester/processes/macos.rs b/src/app/data_harvester/processes/macos.rs index f0c3980d..f08e17ca 100644 --- a/src/app/data_harvester/processes/macos.rs +++ b/src/app/data_harvester/processes/macos.rs @@ -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], @@ -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(); @@ -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 { diff --git a/src/app/data_harvester/processes/windows.rs b/src/app/data_harvester/processes/windows.rs index 08cde500..af9ead5f 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::{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(); @@ -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 { diff --git a/src/app/data_harvester/temperature/sysinfo.rs b/src/app/data_harvester/temperature/sysinfo.rs index f0f79b1a..bc246636 100644 --- a/src/app/data_harvester/temperature/sysinfo.rs +++ b/src/app/data_harvester/temperature/sysinfo.rs @@ -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()) } }, }); |