diff --git a/Cargo.lock b/Cargo.lock index b5100a8..911a96f 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -279,7 +279,7 @@ checksum = "a1d728cc89cf3aee9ff92b05e62b19ee65a02b5702cff7d5a377e32c6ae29d8d" [[package]] name = "cm-dashboard" -version = "0.1.239" +version = "0.1.240" dependencies = [ "anyhow", "chrono", @@ -301,7 +301,7 @@ dependencies = [ [[package]] name = "cm-dashboard-agent" -version = "0.1.239" +version = "0.1.240" dependencies = [ "anyhow", "async-trait", @@ -325,7 +325,7 @@ dependencies = [ [[package]] name = "cm-dashboard-shared" -version = "0.1.239" +version = "0.1.240" dependencies = [ "chrono", "serde", diff --git a/agent/Cargo.toml b/agent/Cargo.toml index e9588cd..29be315 100644 --- a/agent/Cargo.toml +++ b/agent/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "cm-dashboard-agent" -version = "0.1.240" +version = "0.1.241" edition = "2021" [dependencies] diff --git a/agent/src/collectors/cpu.rs b/agent/src/collectors/cpu.rs index 7165b18..60e4172 100644 --- a/agent/src/collectors/cpu.rs +++ b/agent/src/collectors/cpu.rs @@ -129,9 +129,11 @@ impl CpuCollector { for line in content.lines() { if line.starts_with("model name") { if let Some(colon_pos) = line.find(':') { - let name = line[colon_pos + 1..].trim().to_string(); + let full_name = line[colon_pos + 1..].trim(); + // Extract just the model number (e.g., "i7-9700" from "Intel(R) Core(TM) i7-9700 CPU @ 3.00GHz") + let model = Self::extract_cpu_model(full_name); if model_name.is_none() { - model_name = Some(name); + model_name = Some(model); } } } else if line.starts_with("processor") { @@ -147,6 +149,51 @@ impl CpuCollector { Ok(()) } + /// Extract CPU model number from full model name + /// Examples: + /// - "Intel(R) Core(TM) i7-9700 CPU @ 3.00GHz" -> "i7-9700" + /// - "AMD Ryzen 9 5950X 16-Core Processor" -> "Ryzen 9 5950X" + fn extract_cpu_model(full_name: &str) -> String { + // Look for common Intel patterns: i3, i5, i7, i9, Xeon + if let Some(pos) = full_name.find("i3-") { + if let Some(end) = full_name[pos..].find(' ') { + return full_name[pos..pos + end].to_string(); + } + } + if let Some(pos) = full_name.find("i5-") { + if let Some(end) = full_name[pos..].find(' ') { + return full_name[pos..pos + end].to_string(); + } + } + if let Some(pos) = full_name.find("i7-") { + if let Some(end) = full_name[pos..].find(' ') { + return full_name[pos..pos + end].to_string(); + } + } + if let Some(pos) = full_name.find("i9-") { + if let Some(end) = full_name[pos..].find(' ') { + return full_name[pos..pos + end].to_string(); + } + } + + // Look for AMD Ryzen pattern + if let Some(pos) = full_name.find("Ryzen") { + // Extract "Ryzen X XXXX" pattern + let after_ryzen = &full_name[pos..]; + let parts: Vec<&str> = after_ryzen.split_whitespace().collect(); + if parts.len() >= 3 { + return format!("{} {} {}", parts[0], parts[1], parts[2]); + } + } + + // Fallback: return first 20 characters or full name if shorter + if full_name.len() > 20 { + full_name[..20].to_string() + } else { + full_name.to_string() + } + } + /// Collect CPU C-state (idle depth) and populate AgentData with top 3 C-states by usage async fn collect_cstate(&self, agent_data: &mut AgentData) -> Result<(), CollectorError> { // Read C-state usage from first CPU (representative of overall system) diff --git a/dashboard/Cargo.toml b/dashboard/Cargo.toml index 919442b..7a7e2c0 100644 --- a/dashboard/Cargo.toml +++ b/dashboard/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "cm-dashboard" -version = "0.1.240" +version = "0.1.241" edition = "2021" [dependencies] diff --git a/shared/Cargo.toml b/shared/Cargo.toml index 466e1b0..5fb7bb8 100644 --- a/shared/Cargo.toml +++ b/shared/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "cm-dashboard-shared" -version = "0.1.240" +version = "0.1.241" edition = "2021" [dependencies]