diff --git a/pbs-api-types/src/lib.rs b/pbs-api-types/src/lib.rs index 508ee111..4306eca3 100644 --- a/pbs-api-types/src/lib.rs +++ b/pbs-api-types/src/lib.rs @@ -84,6 +84,9 @@ pub use maintenance::*; mod network; pub use network::*; +mod node; +pub use node::*; + pub use proxmox_auth_api::types as userid; pub use proxmox_auth_api::types::{Authid, Userid}; pub use proxmox_auth_api::types::{Realm, RealmRef}; diff --git a/pbs-api-types/src/node.rs b/pbs-api-types/src/node.rs new file mode 100644 index 00000000..704215bb --- /dev/null +++ b/pbs-api-types/src/node.rs @@ -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, +}