first commit

This commit is contained in:
FantasyPvP
2024-10-15 01:15:47 +01:00
commit 5e9d5f5c3b
4 changed files with 574 additions and 0 deletions
+74
View File
@@ -0,0 +1,74 @@
use std::process::Command;
use sysinfo::{Components, Disks, Networks, System};
static LOGO: &str = "       'xkXxdxddd,oddc. .  'c:     
     MM0d' :kk' 'ldddx0OkMMMMMMXOxdxKk.  
      NO;oo.  .co;;:cxMMMMMMMMMMMMMMMMM   
   dxc;dxccco:l,''....XMMMMM',xK0lkMM  
  'dX:cMMMll;MMMMMMMMMMMkk: ..::oXx 
 .MlcMM0 M0  co: ....  
  xM WMM'oM,  ;oooxMM 
   Oo.MMM MM     
  lXNMMWocKMMMMMMMMMMMMMMMMMMMd 
  .co0MMM0:codMMMMKMWdddoMMMMMM..  
 .od0MMMM:  OMMMxN:  olc:;.     
 ::;:::xX: lMMMMKdd..... ,ll 
 .:. cc   OlkWkddddol:.',;:.. .  
 . ;d  :oo .odd: lddddd  .. 
 .;  d,. 'd dol:;. .', 
  :,   . c: .':  
 dKd'do ..    ';c   
  MM0ddd;dkx'  .,c   
 cMMM .XKXMM.  ..,   ";
fn main() {
let info_kernel_out = Command::new("uname")
.arg("-r")
.output()
.expect("failed to fetch kernel ver");
let info_kernel = String::from_utf8_lossy(&info_kernel_out.stdout);
let mut sys = System::new_all();
sys.refresh_all();
let info = vec![
String::new(),
String::new(),
format!("OS Name : {}", System::name().unwrap()),
format!("Kernel : {}", System::kernel_version().unwrap()),
format!("OS Version : {}", System::os_version().unwrap()),
format!("Hostname : {}", System::host_name().unwrap()),
format!("CPU Arch : {}", System::cpu_arch().unwrap()),
format!(
"CPU Cores : {}",
sys.physical_core_count().unwrap().to_string()
),
format!(
"Uptime : {}",
(|| {
let u_s = System::uptime();
format!(
"{} Hours {} Minutes {} Seconds",
u_s / 3600,
u_s % 3600 / 60,
u_s % 60
)
})()
),
format!(
"Memory Use : {}MiB / {}MiB",
sys.used_memory() / 1000000,
sys.total_memory() / 1000000
),
];
println!("\n");
let binding = String::new();
let mut iter = LOGO
.lines()
.zip(info.iter().chain(std::iter::repeat(&binding)));
while let Some((logo, info)) = iter.next() {
println!("{} {}", logo, info);
}
}