Added progress for HDD space
This commit is contained in:
@@ -1,3 +1,3 @@
|
|||||||
[default]
|
[default]
|
||||||
template_dir = "templates"
|
template_dir = "templates"
|
||||||
address = "0.0.0.0"
|
#address = "0.0.0.0"
|
||||||
|
|||||||
12
src/main.rs
12
src/main.rs
@@ -23,7 +23,9 @@ struct ComponentInfo {
|
|||||||
struct DiskInfo {
|
struct DiskInfo {
|
||||||
name: String,
|
name: String,
|
||||||
total_space: String,
|
total_space: String,
|
||||||
|
total_space_bytes: u64,
|
||||||
available_space: String,
|
available_space: String,
|
||||||
|
available_space_bytes: u64,
|
||||||
mount_point: String,
|
mount_point: String,
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -51,15 +53,19 @@ fn get_system_info() -> SysInfo {
|
|||||||
let mut sys = System::new_all();
|
let mut sys = System::new_all();
|
||||||
sys.refresh_all();
|
sys.refresh_all();
|
||||||
let cpu_load = System::load_average();
|
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 disks = Disks::new_with_refreshed_list();
|
||||||
let mut disks_context = Vec::new();
|
let mut disks_context = Vec::new();
|
||||||
for disk in disks.list() {
|
for disk in disks.list() {
|
||||||
|
let ts = disk.total_space();
|
||||||
|
let ass = disk.available_space();
|
||||||
disks_context.push(DiskInfo {
|
disks_context.push(DiskInfo {
|
||||||
name: disk.name().to_str().unwrap().to_string(),
|
name: disk.name().to_str().unwrap().to_string(),
|
||||||
total_space: Byte::from(disk.total_space()).to_string(),
|
total_space: Byte::from(ts).to_string(),
|
||||||
available_space: Byte::from(disk.available_space()).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(),
|
mount_point: disk.mount_point().display().to_string(),
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user