2020-05-23 09:10:02 +00:00
|
|
|
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,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
)]
|
2020-05-23 12:03:44 +00:00
|
|
|
/// Read node stats
|
|
|
|
fn get_node_stats(
|
2020-05-23 09:10:02 +00:00
|
|
|
timeframe: RRDTimeFrameResolution,
|
|
|
|
cf: RRDMode,
|
|
|
|
_param: Value,
|
|
|
|
) -> Result<Value, Error> {
|
|
|
|
|
2020-05-23 13:37:17 +00:00
|
|
|
crate::rrd::extract_data(
|
2020-05-23 12:03:44 +00:00
|
|
|
"host",
|
2020-05-25 09:10:44 +00:00
|
|
|
&[
|
|
|
|
"cpu", "iowait",
|
|
|
|
"memtotal", "memused",
|
|
|
|
"swaptotal", "swapused",
|
|
|
|
"netin", "netout",
|
|
|
|
"roottotal", "rootused",
|
|
|
|
],
|
2020-05-23 12:03:44 +00:00
|
|
|
timeframe,
|
|
|
|
cf,
|
|
|
|
)
|
2020-05-23 09:10:02 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
pub const ROUTER: Router = Router::new()
|
2020-05-23 12:03:44 +00:00
|
|
|
.get(&API_METHOD_GET_NODE_STATS);
|