mirror of
https://git.proxmox.com/git/proxmox-backup
synced 2025-08-13 06:31:19 +00:00
pbs-api-types: move node status types from src/api2/types/mod.rs
Signed-off-by: Dietmar Maurer <dietmar@proxmox.com>
This commit is contained in:
parent
3b60974218
commit
6d33fb6fe3
@ -84,6 +84,9 @@ pub use maintenance::*;
|
|||||||
mod network;
|
mod network;
|
||||||
pub use network::*;
|
pub use network::*;
|
||||||
|
|
||||||
|
mod node;
|
||||||
|
pub use node::*;
|
||||||
|
|
||||||
pub use proxmox_auth_api::types as userid;
|
pub use proxmox_auth_api::types as userid;
|
||||||
pub use proxmox_auth_api::types::{Authid, Userid};
|
pub use proxmox_auth_api::types::{Authid, Userid};
|
||||||
pub use proxmox_auth_api::types::{Realm, RealmRef};
|
pub use proxmox_auth_api::types::{Realm, RealmRef};
|
||||||
|
100
pbs-api-types/src/node.rs
Normal file
100
pbs-api-types/src/node.rs
Normal file
@ -0,0 +1,100 @@
|
|||||||
|
use serde::{Deserialize, Serialize};
|
||||||
|
use proxmox_schema::*;
|
||||||
|
|
||||||
|
use crate::StorageStatus;
|
||||||
|
|
||||||
|
|
||||||
|
#[api]
|
||||||
|
#[derive(Serialize, Deserialize, Default)]
|
||||||
|
#[serde(rename_all = "kebab-case")]
|
||||||
|
/// Node memory usage counters
|
||||||
|
pub struct NodeMemoryCounters {
|
||||||
|
/// Total memory
|
||||||
|
pub total: u64,
|
||||||
|
/// Used memory
|
||||||
|
pub used: u64,
|
||||||
|
/// Free memory
|
||||||
|
pub free: u64,
|
||||||
|
}
|
||||||
|
|
||||||
|
#[api]
|
||||||
|
#[derive(Serialize, Deserialize, Default)]
|
||||||
|
#[serde(rename_all = "kebab-case")]
|
||||||
|
/// Node swap usage counters
|
||||||
|
pub struct NodeSwapCounters {
|
||||||
|
/// Total swap
|
||||||
|
pub total: u64,
|
||||||
|
/// Used swap
|
||||||
|
pub used: u64,
|
||||||
|
/// Free swap
|
||||||
|
pub free: u64,
|
||||||
|
}
|
||||||
|
|
||||||
|
#[api]
|
||||||
|
#[derive(Serialize, Deserialize, Default)]
|
||||||
|
#[serde(rename_all = "kebab-case")]
|
||||||
|
/// Contains general node information such as the fingerprint`
|
||||||
|
pub struct NodeInformation {
|
||||||
|
/// The SSL Fingerprint
|
||||||
|
pub fingerprint: String,
|
||||||
|
}
|
||||||
|
|
||||||
|
#[api]
|
||||||
|
#[derive(Serialize, Deserialize, Default)]
|
||||||
|
#[serde(rename_all = "kebab-case")]
|
||||||
|
/// Information about the CPU
|
||||||
|
pub struct NodeCpuInformation {
|
||||||
|
/// The CPU model
|
||||||
|
pub model: String,
|
||||||
|
/// The number of CPU sockets
|
||||||
|
pub sockets: usize,
|
||||||
|
/// The number of CPU cores (incl. threads)
|
||||||
|
pub cpus: usize,
|
||||||
|
}
|
||||||
|
|
||||||
|
#[api(
|
||||||
|
properties: {
|
||||||
|
memory: {
|
||||||
|
type: NodeMemoryCounters,
|
||||||
|
},
|
||||||
|
root: {
|
||||||
|
type: StorageStatus,
|
||||||
|
},
|
||||||
|
swap: {
|
||||||
|
type: NodeSwapCounters,
|
||||||
|
},
|
||||||
|
loadavg: {
|
||||||
|
type: Array,
|
||||||
|
items: {
|
||||||
|
type: Number,
|
||||||
|
description: "the load",
|
||||||
|
}
|
||||||
|
},
|
||||||
|
cpuinfo: {
|
||||||
|
type: NodeCpuInformation,
|
||||||
|
},
|
||||||
|
info: {
|
||||||
|
type: NodeInformation,
|
||||||
|
}
|
||||||
|
},
|
||||||
|
)]
|
||||||
|
#[derive(Serialize, Deserialize, Default)]
|
||||||
|
#[serde(rename_all = "kebab-case")]
|
||||||
|
/// The Node status
|
||||||
|
pub struct NodeStatus {
|
||||||
|
pub memory: NodeMemoryCounters,
|
||||||
|
pub root: StorageStatus,
|
||||||
|
pub swap: NodeSwapCounters,
|
||||||
|
/// The current uptime of the server.
|
||||||
|
pub uptime: u64,
|
||||||
|
/// Load for 1, 5 and 15 minutes.
|
||||||
|
pub loadavg: [f64; 3],
|
||||||
|
/// The current kernel version.
|
||||||
|
pub kversion: String,
|
||||||
|
/// Total CPU usage since last query.
|
||||||
|
pub cpu: f64,
|
||||||
|
/// Total IO wait since last query.
|
||||||
|
pub wait: f64,
|
||||||
|
pub cpuinfo: NodeCpuInformation,
|
||||||
|
pub info: NodeInformation,
|
||||||
|
}
|
@ -13,17 +13,15 @@ use pbs_api_types::{
|
|||||||
NodePowerCommand, StorageStatus, NODE_SCHEMA, PRIV_SYS_AUDIT, PRIV_SYS_POWER_MANAGEMENT,
|
NodePowerCommand, StorageStatus, NODE_SCHEMA, PRIV_SYS_AUDIT, PRIV_SYS_POWER_MANAGEMENT,
|
||||||
};
|
};
|
||||||
|
|
||||||
use crate::api2::types::{
|
use pbs_api_types::{
|
||||||
NodeCpuInformation, NodeInformation, NodeMemoryCounters, NodeStatus, NodeSwapCounters,
|
NodeCpuInformation, NodeInformation, NodeMemoryCounters, NodeStatus, NodeSwapCounters,
|
||||||
};
|
};
|
||||||
|
|
||||||
impl std::convert::From<procfs::ProcFsCPUInfo> for NodeCpuInformation {
|
fn procfs_to_node_cpu_info(info: procfs::ProcFsCPUInfo) -> NodeCpuInformation {
|
||||||
fn from(info: procfs::ProcFsCPUInfo) -> Self {
|
NodeCpuInformation {
|
||||||
Self {
|
model: info.model,
|
||||||
model: info.model,
|
sockets: info.sockets,
|
||||||
sockets: info.sockets,
|
cpus: info.cpus,
|
||||||
cpus: info.cpus,
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -69,7 +67,7 @@ async fn get_status(
|
|||||||
let loadavg = [loadavg.one(), loadavg.five(), loadavg.fifteen()];
|
let loadavg = [loadavg.one(), loadavg.five(), loadavg.fifteen()];
|
||||||
|
|
||||||
let cpuinfo = procfs::read_cpuinfo()?;
|
let cpuinfo = procfs::read_cpuinfo()?;
|
||||||
let cpuinfo = cpuinfo.into();
|
let cpuinfo = procfs_to_node_cpu_info(cpuinfo);
|
||||||
|
|
||||||
let uname = nix::sys::utsname::uname()?;
|
let uname = nix::sys::utsname::uname()?;
|
||||||
let kversion = format!(
|
let kversion = format!(
|
||||||
|
@ -1,12 +1,9 @@
|
|||||||
//! API Type Definitions
|
//! API Type Definitions
|
||||||
|
|
||||||
use anyhow::bail;
|
use anyhow::bail;
|
||||||
use serde::{Deserialize, Serialize};
|
|
||||||
|
|
||||||
use proxmox_schema::*;
|
use proxmox_schema::*;
|
||||||
|
|
||||||
use pbs_api_types::StorageStatus;
|
|
||||||
|
|
||||||
mod acme;
|
mod acme;
|
||||||
pub use acme::*;
|
pub use acme::*;
|
||||||
|
|
||||||
@ -123,101 +120,6 @@ fn test_proxmox_user_id_schema() -> Result<(), anyhow::Error> {
|
|||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
#[api]
|
|
||||||
#[derive(Serialize, Deserialize, Default)]
|
|
||||||
#[serde(rename_all = "kebab-case")]
|
|
||||||
/// Node memory usage counters
|
|
||||||
pub struct NodeMemoryCounters {
|
|
||||||
/// Total memory
|
|
||||||
pub total: u64,
|
|
||||||
/// Used memory
|
|
||||||
pub used: u64,
|
|
||||||
/// Free memory
|
|
||||||
pub free: u64,
|
|
||||||
}
|
|
||||||
|
|
||||||
#[api]
|
|
||||||
#[derive(Serialize, Deserialize, Default)]
|
|
||||||
#[serde(rename_all = "kebab-case")]
|
|
||||||
/// Node swap usage counters
|
|
||||||
pub struct NodeSwapCounters {
|
|
||||||
/// Total swap
|
|
||||||
pub total: u64,
|
|
||||||
/// Used swap
|
|
||||||
pub used: u64,
|
|
||||||
/// Free swap
|
|
||||||
pub free: u64,
|
|
||||||
}
|
|
||||||
|
|
||||||
#[api]
|
|
||||||
#[derive(Serialize, Deserialize, Default)]
|
|
||||||
#[serde(rename_all = "kebab-case")]
|
|
||||||
/// Contains general node information such as the fingerprint`
|
|
||||||
pub struct NodeInformation {
|
|
||||||
/// The SSL Fingerprint
|
|
||||||
pub fingerprint: String,
|
|
||||||
}
|
|
||||||
|
|
||||||
#[api]
|
|
||||||
#[derive(Serialize, Deserialize, Default)]
|
|
||||||
#[serde(rename_all = "kebab-case")]
|
|
||||||
/// Information about the CPU
|
|
||||||
pub struct NodeCpuInformation {
|
|
||||||
/// The CPU model
|
|
||||||
pub model: String,
|
|
||||||
/// The number of CPU sockets
|
|
||||||
pub sockets: usize,
|
|
||||||
/// The number of CPU cores (incl. threads)
|
|
||||||
pub cpus: usize,
|
|
||||||
}
|
|
||||||
|
|
||||||
#[api(
|
|
||||||
properties: {
|
|
||||||
memory: {
|
|
||||||
type: NodeMemoryCounters,
|
|
||||||
},
|
|
||||||
root: {
|
|
||||||
type: StorageStatus,
|
|
||||||
},
|
|
||||||
swap: {
|
|
||||||
type: NodeSwapCounters,
|
|
||||||
},
|
|
||||||
loadavg: {
|
|
||||||
type: Array,
|
|
||||||
items: {
|
|
||||||
type: Number,
|
|
||||||
description: "the load",
|
|
||||||
}
|
|
||||||
},
|
|
||||||
cpuinfo: {
|
|
||||||
type: NodeCpuInformation,
|
|
||||||
},
|
|
||||||
info: {
|
|
||||||
type: NodeInformation,
|
|
||||||
}
|
|
||||||
},
|
|
||||||
)]
|
|
||||||
#[derive(Serialize, Deserialize, Default)]
|
|
||||||
#[serde(rename_all = "kebab-case")]
|
|
||||||
/// The Node status
|
|
||||||
pub struct NodeStatus {
|
|
||||||
pub memory: NodeMemoryCounters,
|
|
||||||
pub root: StorageStatus,
|
|
||||||
pub swap: NodeSwapCounters,
|
|
||||||
/// The current uptime of the server.
|
|
||||||
pub uptime: u64,
|
|
||||||
/// Load for 1, 5 and 15 minutes.
|
|
||||||
pub loadavg: [f64; 3],
|
|
||||||
/// The current kernel version.
|
|
||||||
pub kversion: String,
|
|
||||||
/// Total CPU usage since last query.
|
|
||||||
pub cpu: f64,
|
|
||||||
/// Total IO wait since last query.
|
|
||||||
pub wait: f64,
|
|
||||||
pub cpuinfo: NodeCpuInformation,
|
|
||||||
pub info: NodeInformation,
|
|
||||||
}
|
|
||||||
|
|
||||||
pub const HTTP_PROXY_SCHEMA: Schema =
|
pub const HTTP_PROXY_SCHEMA: Schema =
|
||||||
StringSchema::new("HTTP proxy configuration [http://]<host>[:port]")
|
StringSchema::new("HTTP proxy configuration [http://]<host>[:port]")
|
||||||
.format(&ApiStringFormat::VerifyFn(|s| {
|
.format(&ApiStringFormat::VerifyFn(|s| {
|
||||||
|
Loading…
Reference in New Issue
Block a user