Get random sysinfo & print to terminal

This commit is contained in:
Sebastian Cabrera 2024-06-21 18:35:22 -04:00
parent 73aeab77e1
commit b92b5430e1
No known key found for this signature in database
GPG key ID: 9C70960A46161D08
3 changed files with 20 additions and 1 deletions

View file

@ -4,3 +4,4 @@ version = "0.1.0"
edition = "2021" edition = "2021"
[dependencies] [dependencies]
sysinfo = "0.30.12"

BIN
src/main

Binary file not shown.

View file

@ -1,3 +1,21 @@
use sysinfo::System;
fn main() { fn main() {
println!("Hello, world!"); get_sys_info()
}
fn get_sys_info() {
let mut sys = System::new_all();
// First we update all information of our `System` struct.
sys.refresh_all();
// Display system information:
println!("System name: {:?}", System::name());
println!("Kernel version: {:?}", System::kernel_version());
println!("System OS version: {:?}", System::os_version());
println!("System host name: {:?}", System::host_name());
// Number of CPUs:
println!("Number of CPUs: {}", sys.cpus().len());
} }