Added progress for HDD space

This commit is contained in:
2024-05-09 21:33:25 +01:00
parent 39cfdbfe4c
commit 0ec598eadb
2 changed files with 10 additions and 4 deletions

View File

@@ -1,3 +1,3 @@
[default]
template_dir = "templates"
address = "0.0.0.0"
#address = "0.0.0.0"

View File

@@ -23,7 +23,9 @@ struct ComponentInfo {
struct DiskInfo {
name: String,
total_space: String,
total_space_bytes: u64,
available_space: String,
available_space_bytes: u64,
mount_point: String,
}
@@ -51,15 +53,19 @@ fn get_system_info() -> SysInfo {
let mut sys = System::new_all();
sys.refresh_all();
let cpu_load = System::load_average();
let cpu_load = (format!("{:.3}", cpu_load.one), format!("{:.3}", cpu_load.five), format!("{:.3}", cpu_load.fifteen));
let cpu_load = (format!("{:.2}", cpu_load.one), format!("{:.2}", cpu_load.five), format!("{:.2}", cpu_load.fifteen));
let disks = Disks::new_with_refreshed_list();
let mut disks_context = Vec::new();
for disk in disks.list() {
let ts = disk.total_space();
let ass = disk.available_space();
disks_context.push(DiskInfo {
name: disk.name().to_str().unwrap().to_string(),
total_space: Byte::from(disk.total_space()).to_string(),
available_space: Byte::from(disk.available_space()).to_string(),
total_space: Byte::from(ts).to_string(),
total_space_bytes: ts,
available_space: Byte::from(ass).to_string(),
available_space_bytes: ass,
mount_point: disk.mount_point().display().to_string(),
});
}