️ Improve metrics consistency

This commit is contained in:
andreas.dinauer 2025-11-16 15:15:32 +01:00
parent 3c03f77ddf
commit 5cd3293aae

View File

@ -14,22 +14,22 @@ fn index() -> Result<String, Status> {
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])
}