summaryrefslogtreecommitdiffstats
path: root/src/app/data_harvester/processes/unix.rs
blob: 1d42c2ca548fe5a5c0f7480b8960d7fcf9d4276c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
//! Unix-specific parts of process collection.

mod user_table;
use cfg_if::cfg_if;
pub use user_table::*;

cfg_if! {
    if #[cfg(all(target_family = "unix", not(target_os = "linux")))] {
        mod process_ext;
        pub(crate) use process_ext::*;

        use super::ProcessHarvest;

        use crate::app::data_harvester::{DataCollector, processes::*};
        use crate::utils::error;

        pub fn sysinfo_process_data(collector: &mut DataCollector) -> error::Result<Vec<ProcessHarvest>> {
            let sys = &collector.sys;
            let use_current_cpu_total = collector.use_current_cpu_total;
            let unnormalized_cpu = collector.unnormalized_cpu;
            let total_memory = collector.total_memory();
            let user_table = &mut collector.user_table;

            cfg_if! {
                if #[cfg(target_os = "macos")] {
                    MacOSProcessExt::sysinfo_process_data(sys, use_current_cpu_total, unnormalized_cpu, total_memory, user_table)
                } else if #[cfg(target_os = "freebsd")] {
                    FreeBSDProcessExt::sysinfo_process_data(sys, use_current_cpu_total, unnormalized_cpu, total_memory, user_table)
                } else {
                    GenericProcessExt::sysinfo_process_data(sys, use_current_cpu_total, unnormalized_cpu, total_memory, user_table)
                }
            }
        }

    }
}