mirror of
https://git.proxmox.com/git/proxmox
synced 2025-08-06 06:32:36 +00:00
api2/status: use new rrd::extract_cached_data
and drop the now unused extract_lists function this also fixes a bug, where we did not add the datastore to the list at all when there was no rrd data Signed-off-by: Dominik Csapak <d.csapak@proxmox.com> Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
This commit is contained in:
parent
11cb8cd008
commit
50fa6045b3
@ -65,43 +65,6 @@ pub fn update_value(rel_path: &str, value: f64, dst: DST, save: bool) -> Result<
|
|||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
/// extracts the lists of the given items and a list of timestamps
|
|
||||||
pub fn extract_lists(
|
|
||||||
base: &str,
|
|
||||||
items: &[&str],
|
|
||||||
timeframe: RRDTimeFrameResolution,
|
|
||||||
mode: RRDMode,
|
|
||||||
) -> Result<(Vec<u64>, HashMap<String, Vec<Option<f64>>>), Error> {
|
|
||||||
|
|
||||||
let now = now()?;
|
|
||||||
|
|
||||||
let map = RRD_CACHE.read().unwrap();
|
|
||||||
|
|
||||||
let mut result = HashMap::new();
|
|
||||||
|
|
||||||
let mut times = Vec::new();
|
|
||||||
|
|
||||||
for name in items.iter() {
|
|
||||||
let rrd = match map.get(&format!("{}/{}", base, name)) {
|
|
||||||
Some(rrd) => rrd,
|
|
||||||
None => continue,
|
|
||||||
};
|
|
||||||
let (start, reso, list) = rrd.extract_data(now, timeframe, mode);
|
|
||||||
|
|
||||||
result.insert(name.to_string(), list);
|
|
||||||
|
|
||||||
if times.len() == 0 {
|
|
||||||
let mut t = start;
|
|
||||||
for _ in 0..RRD_DATA_ENTRIES {
|
|
||||||
times.push(t);
|
|
||||||
t += reso;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
Ok((times, result))
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn extract_cached_data(
|
pub fn extract_cached_data(
|
||||||
base: &str,
|
base: &str,
|
||||||
name: &str,
|
name: &str,
|
||||||
|
Loading…
Reference in New Issue
Block a user