From 5cd3293aae2878a4fac08bb64afb510213b1eb2c Mon Sep 17 00:00:00 2001 From: "andreas.dinauer" Date: Sun, 16 Nov 2025 15:15:32 +0100 Subject: [PATCH] =?UTF-8?q?=E2=9A=A1=EF=B8=8F=20Improve=20metrics=20consis?= =?UTF-8?q?tency?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main.rs | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) 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]) }