update to rrd-api-types 1.0.2

Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
This commit is contained in:
Wolfgang Bumiller 2024-09-19 15:21:45 +02:00
parent 79ed296f2d
commit 93e9e8b6ef
6 changed files with 26 additions and 26 deletions

View File

@ -76,7 +76,7 @@ proxmox-rest-server = { version = "0.8", features = [ "templates" ] }
# some use "cli", some use "cli" and "server", pbs-config uses nothing
proxmox-router = { version = "3.0.0", default-features = false }
proxmox-rrd = "0.4"
proxmox-rrd-api-types = "1"
proxmox-rrd-api-types = "1.0.2"
# everything but pbs-config and pbs-client use "api-macro"
proxmox-schema = "3"
proxmox-section-config = "2"

2
debian/control vendored
View File

@ -83,7 +83,7 @@ Build-Depends: bash-completion,
librust-proxmox-router-3+cli-dev,
librust-proxmox-router-3+server-dev,
librust-proxmox-rrd-0.4+default-dev,
librust-proxmox-rrd-api-types-1+default-dev,
librust-proxmox-rrd-api-types-1+default-dev (>= 1.0.2-~~),
librust-proxmox-schema-3+api-macro-dev,
librust-proxmox-schema-3+default-dev,
librust-proxmox-section-config-2+default-dev,

View File

@ -22,7 +22,7 @@ use proxmox_router::{
http_err, list_subdirs_api_method, ApiHandler, ApiMethod, ApiResponseFuture, Permission,
Router, RpcEnvironment, RpcEnvironmentType, SubdirMap,
};
use proxmox_rrd_api_types::{RRDMode, RRDTimeFrame};
use proxmox_rrd_api_types::{RrdMode, RrdTimeframe};
use proxmox_schema::*;
use proxmox_sortable_macro::sortable;
use proxmox_sys::fs::{
@ -1925,10 +1925,10 @@ pub fn pxar_file_download(
schema: DATASTORE_SCHEMA,
},
timeframe: {
type: RRDTimeFrame,
type: RrdTimeframe,
},
cf: {
type: RRDMode,
type: RrdMode,
},
},
},
@ -1940,8 +1940,8 @@ pub fn pxar_file_download(
/// Read datastore stats
pub fn get_rrd_stats(
store: String,
timeframe: RRDTimeFrame,
cf: RRDMode,
timeframe: RrdTimeframe,
cf: RrdMode,
_param: Value,
) -> Result<Value, Error> {
let datastore = DataStore::lookup_datastore(&store, Some(Operation::Read))?;

View File

@ -3,7 +3,7 @@ use serde_json::{json, Value};
use std::collections::BTreeMap;
use proxmox_router::{Permission, Router};
use proxmox_rrd_api_types::{RRDMode, RRDTimeFrame};
use proxmox_rrd_api_types::{RrdMode, RrdTimeframe};
use proxmox_schema::api;
use pbs_api_types::{NODE_SCHEMA, PRIV_SYS_AUDIT};
@ -13,8 +13,8 @@ use crate::rrd_cache::extract_rrd_data;
pub fn create_value_from_rrd(
basedir: &str,
list: &[&str],
timeframe: RRDTimeFrame,
mode: RRDMode,
timeframe: RrdTimeframe,
mode: RrdMode,
) -> Result<Value, Error> {
let mut result: Vec<Value> = Vec::new();
@ -65,10 +65,10 @@ pub fn create_value_from_rrd(
schema: NODE_SCHEMA,
},
timeframe: {
type: RRDTimeFrame,
type: RrdTimeframe,
},
cf: {
type: RRDMode,
type: RrdMode,
},
},
},
@ -77,7 +77,7 @@ pub fn create_value_from_rrd(
},
)]
/// Read node stats
fn get_node_stats(timeframe: RRDTimeFrame, cf: RRDMode, _param: Value) -> Result<Value, Error> {
fn get_node_stats(timeframe: RrdTimeframe, cf: RrdMode, _param: Value) -> Result<Value, Error> {
create_value_from_rrd(
"host",
&[

View File

@ -5,7 +5,7 @@ use serde_json::Value;
use proxmox_router::list_subdirs_api_method;
use proxmox_router::{ApiMethod, Permission, Router, RpcEnvironment, SubdirMap};
use proxmox_rrd_api_types::{RRDMode, RRDTimeFrame};
use proxmox_rrd_api_types::{RrdMode, RrdTimeframe};
use proxmox_schema::api;
use pbs_api_types::{
@ -82,7 +82,7 @@ pub async fn datastore_status(
let rrd_dir = format!("datastore/{}", store);
let get_rrd =
|what: &str| extract_rrd_data(&rrd_dir, what, RRDTimeFrame::Month, RRDMode::Average);
|what: &str| extract_rrd_data(&rrd_dir, what, RrdTimeframe::Month, RrdMode::Average);
let total_res = get_rrd("total")?;
let used_res = get_rrd("used")?;

View File

@ -14,7 +14,7 @@ use proxmox_rrd::Cache;
use proxmox_sys::fs::CreateOptions;
use pbs_buildcfg::PROXMOX_BACKUP_STATE_DIR_M;
use proxmox_rrd_api_types::{RRDMode, RRDTimeFrame};
use proxmox_rrd_api_types::{RrdMode, RrdTimeframe};
const RRD_CACHE_BASEDIR: &str = concat!(PROXMOX_BACKUP_STATE_DIR_M!(), "/rrdb");
@ -94,23 +94,23 @@ fn create_callback(dst: DataSourceType) -> Database {
pub fn extract_rrd_data(
basedir: &str,
name: &str,
timeframe: RRDTimeFrame,
mode: RRDMode,
timeframe: RrdTimeframe,
mode: RrdMode,
) -> Result<Option<proxmox_rrd::Entry>, Error> {
let end = proxmox_time::epoch_f64() as u64;
let (start, resolution) = match timeframe {
RRDTimeFrame::Hour => (end - 3600, 60),
RRDTimeFrame::Day => (end - 3600 * 24, 60),
RRDTimeFrame::Week => (end - 3600 * 24 * 7, 30 * 60),
RRDTimeFrame::Month => (end - 3600 * 24 * 30, 30 * 60),
RRDTimeFrame::Year => (end - 3600 * 24 * 365, 6 * 60 * 60),
RRDTimeFrame::Decade => (end - 10 * 3600 * 24 * 366, 7 * 86400),
RrdTimeframe::Hour => (end - 3600, 60),
RrdTimeframe::Day => (end - 3600 * 24, 60),
RrdTimeframe::Week => (end - 3600 * 24 * 7, 30 * 60),
RrdTimeframe::Month => (end - 3600 * 24 * 30, 30 * 60),
RrdTimeframe::Year => (end - 3600 * 24 * 365, 6 * 60 * 60),
RrdTimeframe::Decade => (end - 10 * 3600 * 24 * 366, 7 * 86400),
};
let cf = match mode {
RRDMode::Max => AggregationFn::Maximum,
RRDMode::Average => AggregationFn::Average,
RrdMode::Max => AggregationFn::Maximum,
RrdMode::Average => AggregationFn::Average,
};
let rrd_cache = get_rrd_cache()?;