proxmox-rrd: pass time and value to update function
This commit is contained in:
parent
fae4f6c509
commit
58f70bccbb
@ -244,24 +244,23 @@ impl RRDCache {
|
||||
pub fn update_value(
|
||||
&self,
|
||||
rel_path: &str,
|
||||
time: f64,
|
||||
value: f64,
|
||||
dst: DST,
|
||||
) -> Result<(), Error> {
|
||||
|
||||
let mut state = self.state.write().unwrap(); // block other writers
|
||||
|
||||
let now = proxmox_time::epoch_f64();
|
||||
|
||||
if (now - state.last_journal_flush) > self.apply_interval {
|
||||
if (time - state.last_journal_flush) > self.apply_interval {
|
||||
if let Err(err) = self.apply_journal_locked(&mut state) {
|
||||
log::error!("apply journal failed: {}", err);
|
||||
}
|
||||
}
|
||||
|
||||
Self::append_journal_entry(&mut state, now, value, dst, rel_path)?;
|
||||
Self::append_journal_entry(&mut state, time, value, dst, rel_path)?;
|
||||
|
||||
if let Some(rrd) = state.rrd_map.get_mut(rel_path) {
|
||||
rrd.update(now, value);
|
||||
rrd.update(time, value);
|
||||
} else {
|
||||
let mut path = self.basedir.clone();
|
||||
path.push(rel_path);
|
||||
@ -269,7 +268,7 @@ impl RRDCache {
|
||||
|
||||
let mut rrd = Self::load_rrd(&path, dst);
|
||||
|
||||
rrd.update(now, value);
|
||||
rrd.update(time, value);
|
||||
state.rrd_map.insert(rel_path.into(), rrd);
|
||||
}
|
||||
|
||||
|
@ -76,7 +76,8 @@ pub fn extract_rrd_data(
|
||||
/// Update RRD Gauge values
|
||||
pub fn rrd_update_gauge(name: &str, value: f64) {
|
||||
if let Ok(rrd_cache) = get_rrd_cache() {
|
||||
if let Err(err) = rrd_cache.update_value(name, value, DST::Gauge) {
|
||||
let now = proxmox_time::epoch_f64();
|
||||
if let Err(err) = rrd_cache.update_value(name, now, value, DST::Gauge) {
|
||||
log::error!("rrd::update_value '{}' failed - {}", name, err);
|
||||
}
|
||||
}
|
||||
@ -85,7 +86,8 @@ pub fn rrd_update_gauge(name: &str, value: f64) {
|
||||
/// Update RRD Derive values
|
||||
pub fn rrd_update_derive(name: &str, value: f64) {
|
||||
if let Ok(rrd_cache) = get_rrd_cache() {
|
||||
if let Err(err) = rrd_cache.update_value(name, value, DST::Derive) {
|
||||
let now = proxmox_time::epoch_f64();
|
||||
if let Err(err) = rrd_cache.update_value(name, now, value, DST::Derive) {
|
||||
log::error!("rrd::update_value '{}' failed - {}", name, err);
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user