-
Notifications
You must be signed in to change notification settings - Fork 115
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #314 from Hwatwasthat/master
Updated some examples to a bit more than printing debug.
- Loading branch information
Showing
3 changed files
with
42 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,19 @@ | ||
// List mountpoints listed in /proc/mounts | ||
|
||
fn main() { | ||
let width = 15; | ||
for mount_entry in procfs::mounts().unwrap() { | ||
println!("{mount_entry:?}"); | ||
println!("Device: {}", mount_entry.fs_spec); | ||
println!("{:>width$}: {}", "Mount point", mount_entry.fs_file); | ||
println!("{:>width$}: {}","FS type", mount_entry.fs_vfstype); | ||
println!("{:>width$}: {}", "Dump", mount_entry.fs_freq); | ||
println!("{:>width$}: {}", "Check", mount_entry.fs_passno); | ||
print!("{:>width$}: ", "Options"); | ||
for (name, entry) in mount_entry.fs_mntops { | ||
if let Some(entry) = entry { | ||
print!("{name}: {entry} "); | ||
} | ||
} | ||
println!(""); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,30 @@ | ||
use procfs::prelude::*; | ||
use procfs::{prelude::*, CpuPressure, IoPressure, MemoryPressure, PressureRecord}; | ||
|
||
/// A basic example of /proc/pressure/ usage. | ||
fn main() { | ||
println!("memory pressure: {:#?}", procfs::MemoryPressure::current()); | ||
println!("cpu pressure: {:#?}", procfs::CpuPressure::current()); | ||
println!("io pressure: {:#?}", procfs::IoPressure::current()); | ||
if let Ok(pressure) = MemoryPressure::current() { | ||
println!("Memory Pressure:"); | ||
println!("{:>10}:", "Some"); | ||
print_pressure(pressure.some, 20); | ||
println!("{:>10}:", "Full"); | ||
print_pressure(pressure.full, 20); | ||
} | ||
if let Ok(pressure) = CpuPressure::current() { | ||
println!("CPU Pressure:"); | ||
print_pressure(pressure.some, 20); | ||
} | ||
if let Ok(pressure) = IoPressure::current() { | ||
println!("IO Pressure:"); | ||
println!("{:>10}:", "Some"); | ||
print_pressure(pressure.some, 20); | ||
println!("{:>10}:", "Full"); | ||
print_pressure(pressure.full, 20); | ||
} | ||
} | ||
|
||
fn print_pressure(pressure: PressureRecord, width: usize) { | ||
println!("{:>width$}: {}", "Average 10", pressure.avg10); | ||
println!("{:>width$}: {}", "Average 60", pressure.avg60); | ||
println!("{:>width$}: {}", "Average 300", pressure.avg300); | ||
println!("{:>width$}: {}", "Total", pressure.total); | ||
} |