feat: add CPU, memory and node status info to cluster_info (#6897)

* feat: add CPU and memory info to `cluster_info`

Signed-off-by: WenyXu <wenymedia@gmail.com>

* feat: add `node_status` to `cluster_info` table

Signed-off-by: WenyXu <wenymedia@gmail.com>

* test: update sqlness

Signed-off-by: WenyXu <wenymedia@gmail.com>

* chore: apply suggestions

Signed-off-by: WenyXu <wenymedia@gmail.com>

* chore: update proto

Signed-off-by: WenyXu <wenymedia@gmail.com>

---------

Signed-off-by: WenyXu <wenymedia@gmail.com>
This commit is contained in:
Weny Xu
2025-09-08 16:59:34 +08:00
committed by GitHub
parent 47384c7701
commit 16febbd4c2
24 changed files with 284 additions and 69 deletions

View File

@@ -39,6 +39,24 @@ pub fn get_sys_total_memory() -> Option<ReadableSize> {
}
}
/// `ResourceSpec` holds the static resource specifications of a node,
/// such as CPU cores and memory capacity. These values are fixed
/// at startup and do not change dynamically during runtime.
#[derive(Debug, Clone, Copy)]
pub struct ResourceSpec {
pub cpus: usize,
pub memory: Option<ReadableSize>,
}
impl Default for ResourceSpec {
fn default() -> Self {
Self {
cpus: get_cpus(),
memory: get_sys_total_memory(),
}
}
}
#[cfg(test)]
mod tests {
use super::*;

View File

@@ -118,6 +118,12 @@ pub struct NodeInfo {
pub git_commit: String,
// The node star timestamp
pub start_time_ms: u64,
// The node build cpus
#[serde(default)]
pub cpus: u32,
// The node build memory bytes
#[serde(default)]
pub memory_bytes: u64,
}
#[derive(Debug, Clone, Copy, Eq, Hash, PartialEq, Serialize, Deserialize)]
@@ -324,6 +330,8 @@ mod tests {
version: "".to_string(),
git_commit: "".to_string(),
start_time_ms: 1,
cpus: 0,
memory_bytes: 0,
};
let node_info_bytes: Vec<u8> = node_info.try_into().unwrap();