diff --git a/src/main.rs b/src/main.rs index b7408f2..6e9bfa7 100644 --- a/src/main.rs +++ b/src/main.rs @@ -14,22 +14,22 @@ fn index() -> Result { if result == 0 { let block_size = stat.f_frsize as u64; let total = stat.f_blocks as u64 * block_size; - let free = stat.f_bfree as u64 * block_size; - let used = total - free; + let available = stat.f_bavail as u64 * block_size; + let used = total - available; let percentage_used = ((used as f64 / total as f64) * 100.0) as u64; + let percentage_available = 100 - percentage_used; - return Ok(format!("path:{}\ntotal-space:{}\nused-space:{}\npercentage_used:{}", host_path,total, used, percentage_used)) + return Ok(format!("path:{}\ntotal-space:{}\nused-space:{}\npercentage-used:{}\npercentage-available{}", host_path,total, used, percentage_used, percentage_available)) } Err(Status::InternalServerError) } #[launch] fn rocket() -> _ { - println!("____ __ __ __ ___ _ __ _ "); println!("__/ |/ /__ ___/ /__ / |/ /__ ___ (_) /____ ____(_)__ ___ _"); println!("_/ / _ \\/ _ / -_) /|_/ / _ \\/ _ \\/ / __/ _ \\/ __/ / _ \\/ _ `/"); println!("/_/|_/\\___/\\_,_/\\__/_/ /_/\\___/_//_/_/\\__/\\___/_/ /_/_//_/\\_, / "); - println!(" /___/ "); + println!(" /___/ "); rocket::custom(rocket::Config { address: "0.0.0.0".parse().unwrap(), port: 8080, ..Default::default() }).mount("/", routes![index]) }