comments
This commit is contained in:
14
main.rs
14
main.rs
@@ -1,34 +1,34 @@
|
|||||||
use std::str;
|
use std::str;
|
||||||
use colored::*;
|
use colored::*; //allow .bright_blue()
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
|
|
||||||
println!("{}", "System info:".bright_blue());
|
println!("{}", "System info:".bright_blue());
|
||||||
|
|
||||||
use sysinfo::{System, SystemExt, DiskExt, ProcessorExt};
|
use sysinfo::{System, SystemExt, DiskExt, ProcessorExt}; //import sys, disk, processor data
|
||||||
|
|
||||||
let sys = System::new_all();
|
let sys = System::new_all();
|
||||||
|
|
||||||
println!("{}", " disks:".bright_blue());
|
println!("{}", " disks:".bright_blue());
|
||||||
println!(" {:32} {:32} {:8} {:8} {:8}",
|
println!(" {:32} {:32} {:8} {:8} {:8}", //heading
|
||||||
"mount:".bright_blue(),
|
"mount:".bright_blue(),
|
||||||
"name:".bright_blue(),
|
"name:".bright_blue(),
|
||||||
"fs:".bright_blue(),
|
"fs:".bright_blue(),
|
||||||
"size:".bright_blue(),
|
"size:".bright_blue(),
|
||||||
"free:".bright_blue());
|
"free:".bright_blue());
|
||||||
for disk in sys.get_disks() {
|
for disk in sys.get_disks() { //print for all disks
|
||||||
println!(" {:32} {:32} {:8} {:8} MB {:8} MB",
|
println!(" {:32} {:32} {:8} {:8} MB {:8} MB",
|
||||||
disk.get_mount_point().display(),
|
disk.get_mount_point().display(),
|
||||||
format!("{}", disk.get_name().to_str().unwrap()),
|
format!("{}", disk.get_name().to_str().unwrap()),
|
||||||
format!("{}", str::from_utf8(disk.get_file_system()).unwrap()),
|
format!("{}", str::from_utf8(disk.get_file_system()).unwrap()),
|
||||||
format!("{}", disk.get_total_space() / 1000000),
|
format!("{}", disk.get_total_space() / 1000000), //space is stored in bytes, convert to MB
|
||||||
format!("{}", disk.get_available_space() / 1000000));
|
format!("{}", disk.get_available_space() / 1000000));
|
||||||
}
|
}
|
||||||
|
|
||||||
println!("{}", " memory:".bright_blue());
|
println!("{}", " memory:".bright_blue());
|
||||||
println!(" {:8} {:<8} MB",
|
println!(" {:8} {:<8} MB",
|
||||||
"total:".bright_blue(),
|
"total:".bright_blue(),
|
||||||
sys.get_total_memory() / 1000);
|
sys.get_total_memory() / 1000); //space is stored in KB, convert to MB
|
||||||
println!(" {:8} {:<8} MB",
|
println!(" {:8} {:<8} MB",
|
||||||
"used:".bright_blue(),
|
"used:".bright_blue(),
|
||||||
sys.get_used_memory() / 1000);
|
sys.get_used_memory() / 1000);
|
||||||
@@ -36,7 +36,7 @@ fn main() {
|
|||||||
println!("{}", " processor:".bright_blue());
|
println!("{}", " processor:".bright_blue());
|
||||||
println!(" {:8} {:64}",
|
println!(" {:8} {:64}",
|
||||||
"brand:".bright_blue(),
|
"brand:".bright_blue(),
|
||||||
sys.get_processors()[0].get_brand());
|
sys.get_processors()[0].get_brand()); //get_global_processor_info() has bug, so get from first core
|
||||||
println!(" {:8} {:<4}",
|
println!(" {:8} {:<4}",
|
||||||
"cores:".bright_blue(),
|
"cores:".bright_blue(),
|
||||||
sys.get_processors().len());
|
sys.get_processors().len());
|
||||||
|
Reference in New Issue
Block a user