add experimental rrd api to get cpu stats

This commit is contained in:
Dietmar Maurer
2020-05-23 11:10:02 +02:00
parent eaeda365e0
commit a2f862eed6
5 changed files with 68 additions and 15 deletions

34
src/api2/node/rrd.rs Normal file
View File

@ -0,0 +1,34 @@
use anyhow::Error;
use serde_json::Value;
use proxmox::api::{api, Router};
use crate::api2::types::*;
#[api(
input: {
properties: {
node: {
schema: NODE_SCHEMA,
},
timeframe: {
type: RRDTimeFrameResolution,
},
cf: {
type: RRDMode,
},
},
},
)]
/// Read CPU stats
fn get_cpu_stats(
timeframe: RRDTimeFrameResolution,
cf: RRDMode,
_param: Value,
) -> Result<Value, Error> {
crate::rrd::extract_data("host/cpu", timeframe, cf)
}
pub const ROUTER: Router = Router::new()
.get(&API_METHOD_GET_CPU_STATS);