let disk_usage return StorageStatus and use it for datastores/nodes

disk_usage returned the same values as defined in StorageStatus,
so simply use that

with that we can replace the logic of the datastore status with that
function and also use it for root disk usage of the nodes

Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
This commit is contained in:
Dominik Csapak
2020-06-09 10:01:09 +02:00
committed by Dietmar Maurer
parent da84cc52f4
commit 33070956af
4 changed files with 18 additions and 24 deletions

View File

@ -1,4 +1,5 @@
use std::process::Command;
use std::path::Path;
use anyhow::{Error, format_err, bail};
use serde_json::{json, Value};
@ -60,6 +61,7 @@ fn get_usage(
let meminfo: procfs::ProcFsMemInfo = procfs::read_meminfo()?;
let kstat: procfs::ProcFsStat = procfs::read_proc_stat()?;
let disk_usage = crate::tools::disks::disk_usage(Path::new("/"))?;
Ok(json!({
"memory": {
@ -68,6 +70,11 @@ fn get_usage(
"free": meminfo.memfree,
},
"cpu": kstat.cpu,
"root": {
"total": disk_usage.total,
"used": disk_usage.used,
"free": disk_usage.avail,
}
}))
}