This is now, how one calculates percentages
This commit is contained in:
parent
d216e8a723
commit
0a71f3ccf8
1 changed files with 5 additions and 3 deletions
|
@ -18,13 +18,15 @@ pub fn get_disks() -> String {
|
|||
.map(|c| {
|
||||
let total_space = c.get_total_space();
|
||||
let available_space = c.get_available_space();
|
||||
let used_space = total_space - available_space;
|
||||
format!(
|
||||
r#""{}": {{"name": {:?}, "total": {}, "free": {}, "used": {}}}"#,
|
||||
r#""{}": {{"name": {:?}, "total": {}, "free": {}, "used": {}, "used_perc": {}}}"#,
|
||||
c.get_mount_point().display(),
|
||||
c.get_name(),
|
||||
total_space,
|
||||
available_space,
|
||||
total_space - available_space,
|
||||
used_space,
|
||||
used_space / total_space,
|
||||
)
|
||||
})
|
||||
.join(",")
|
||||
|
@ -45,7 +47,7 @@ pub fn get_ram() -> String {
|
|||
c.get_free_swap(),
|
||||
c.get_available_memory(),
|
||||
used_memory,
|
||||
used_memory / total_memory,
|
||||
(used_memory / total_memory) * 100,
|
||||
)
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue