Struct nu_system::ProcessInfo

source ·
pub struct ProcessInfo {
    pub pid: i32,
    pub ppid: i32,
    pub curr_proc: ProcessTask,
    pub curr_io: Option<Io>,
    pub prev_io: Option<Io>,
    pub curr_stat: Option<Stat>,
    pub prev_stat: Option<Stat>,
    pub curr_status: Option<Status>,
    pub interval: Duration,
}

Fields§

§pid: i32§ppid: i32§curr_proc: ProcessTask§curr_io: Option<Io>§prev_io: Option<Io>§curr_stat: Option<Stat>§prev_stat: Option<Stat>§curr_status: Option<Status>§interval: Duration

Implementations§

PID of process

Examples found in repository?
examples/sys_demo.rs (line 19)
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
fn main() {
    #[cfg(any(
        target_os = "android",
        target_os = "linux",
        target_os = "macos",
        target_os = "windows"
    ))]
    {
        let cores = match std::thread::available_parallelism() {
            Ok(p) => p.get(),
            Err(_) => 1usize,
        };
        for run in 1..=10 {
            for proc in nu_system::collect_proc(std::time::Duration::from_millis(100), false) {
                if proc.cpu_usage() > 0.00001 {
                    println!(
                        "{} - {} - {} - {} - {:.2}% - {}M - {}M - {} procs",
                        run,
                        proc.pid(),
                        proc.name(),
                        proc.status(),
                        proc.cpu_usage() / cores as f64,
                        proc.mem_size() / (1024 * 1024),
                        proc.virtual_size() / (1024 * 1024),
                        cores,
                    )
                }
            }
            std::thread::sleep(std::time::Duration::from_millis(1000));
        }
    }
}

Name of command

Examples found in repository?
examples/sys_demo.rs (line 20)
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
fn main() {
    #[cfg(any(
        target_os = "android",
        target_os = "linux",
        target_os = "macos",
        target_os = "windows"
    ))]
    {
        let cores = match std::thread::available_parallelism() {
            Ok(p) => p.get(),
            Err(_) => 1usize,
        };
        for run in 1..=10 {
            for proc in nu_system::collect_proc(std::time::Duration::from_millis(100), false) {
                if proc.cpu_usage() > 0.00001 {
                    println!(
                        "{} - {} - {} - {} - {:.2}% - {}M - {}M - {} procs",
                        run,
                        proc.pid(),
                        proc.name(),
                        proc.status(),
                        proc.cpu_usage() / cores as f64,
                        proc.mem_size() / (1024 * 1024),
                        proc.virtual_size() / (1024 * 1024),
                        cores,
                    )
                }
            }
            std::thread::sleep(std::time::Duration::from_millis(1000));
        }
    }
}

Full name of command, with arguments

Get the status of the process

Examples found in repository?
examples/sys_demo.rs (line 21)
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
fn main() {
    #[cfg(any(
        target_os = "android",
        target_os = "linux",
        target_os = "macos",
        target_os = "windows"
    ))]
    {
        let cores = match std::thread::available_parallelism() {
            Ok(p) => p.get(),
            Err(_) => 1usize,
        };
        for run in 1..=10 {
            for proc in nu_system::collect_proc(std::time::Duration::from_millis(100), false) {
                if proc.cpu_usage() > 0.00001 {
                    println!(
                        "{} - {} - {} - {} - {:.2}% - {}M - {}M - {} procs",
                        run,
                        proc.pid(),
                        proc.name(),
                        proc.status(),
                        proc.cpu_usage() / cores as f64,
                        proc.mem_size() / (1024 * 1024),
                        proc.virtual_size() / (1024 * 1024),
                        cores,
                    )
                }
            }
            std::thread::sleep(std::time::Duration::from_millis(1000));
        }
    }
}

CPU usage as a percent of total

Examples found in repository?
examples/sys_demo.rs (line 15)
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
fn main() {
    #[cfg(any(
        target_os = "android",
        target_os = "linux",
        target_os = "macos",
        target_os = "windows"
    ))]
    {
        let cores = match std::thread::available_parallelism() {
            Ok(p) => p.get(),
            Err(_) => 1usize,
        };
        for run in 1..=10 {
            for proc in nu_system::collect_proc(std::time::Duration::from_millis(100), false) {
                if proc.cpu_usage() > 0.00001 {
                    println!(
                        "{} - {} - {} - {} - {:.2}% - {}M - {}M - {} procs",
                        run,
                        proc.pid(),
                        proc.name(),
                        proc.status(),
                        proc.cpu_usage() / cores as f64,
                        proc.mem_size() / (1024 * 1024),
                        proc.virtual_size() / (1024 * 1024),
                        cores,
                    )
                }
            }
            std::thread::sleep(std::time::Duration::from_millis(1000));
        }
    }
}

Memory size in number of bytes

Examples found in repository?
examples/sys_demo.rs (line 23)
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
fn main() {
    #[cfg(any(
        target_os = "android",
        target_os = "linux",
        target_os = "macos",
        target_os = "windows"
    ))]
    {
        let cores = match std::thread::available_parallelism() {
            Ok(p) => p.get(),
            Err(_) => 1usize,
        };
        for run in 1..=10 {
            for proc in nu_system::collect_proc(std::time::Duration::from_millis(100), false) {
                if proc.cpu_usage() > 0.00001 {
                    println!(
                        "{} - {} - {} - {} - {:.2}% - {}M - {}M - {} procs",
                        run,
                        proc.pid(),
                        proc.name(),
                        proc.status(),
                        proc.cpu_usage() / cores as f64,
                        proc.mem_size() / (1024 * 1024),
                        proc.virtual_size() / (1024 * 1024),
                        cores,
                    )
                }
            }
            std::thread::sleep(std::time::Duration::from_millis(1000));
        }
    }
}

Virtual memory size in bytes

Examples found in repository?
examples/sys_demo.rs (line 24)
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
fn main() {
    #[cfg(any(
        target_os = "android",
        target_os = "linux",
        target_os = "macos",
        target_os = "windows"
    ))]
    {
        let cores = match std::thread::available_parallelism() {
            Ok(p) => p.get(),
            Err(_) => 1usize,
        };
        for run in 1..=10 {
            for proc in nu_system::collect_proc(std::time::Duration::from_millis(100), false) {
                if proc.cpu_usage() > 0.00001 {
                    println!(
                        "{} - {} - {} - {} - {:.2}% - {}M - {}M - {} procs",
                        run,
                        proc.pid(),
                        proc.name(),
                        proc.status(),
                        proc.cpu_usage() / cores as f64,
                        proc.mem_size() / (1024 * 1024),
                        proc.virtual_size() / (1024 * 1024),
                        cores,
                    )
                }
            }
            std::thread::sleep(std::time::Duration::from_millis(1000));
        }
    }
}

Auto Trait Implementations§

Blanket Implementations§

Gets the TypeId of self. Read more
Immutably borrows from an owned value. Read more
Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

The type returned in the event of a conversion error.
Performs the conversion.
The type returned in the event of a conversion error.
Performs the conversion.