Fix CPU model extraction for newer Intel generations
All checks were successful
Build and Release / build-and-release (push) Successful in 1m24s
All checks were successful
Build and Release / build-and-release (push) Successful in 1m24s
- Handle 12th/13th Gen Intel format (e.g., "12th Gen Intel(R) Core(TM) i7-12700K") - Extract full model including suffix (i7-12700K instead of truncated name) - Simplify pattern matching logic - Reduce fallback truncation to 15 chars
This commit is contained in:
parent
7a0dc27846
commit
5bb7d6cf57
6
Cargo.lock
generated
6
Cargo.lock
generated
@ -279,7 +279,7 @@ checksum = "a1d728cc89cf3aee9ff92b05e62b19ee65a02b5702cff7d5a377e32c6ae29d8d"
|
||||
|
||||
[[package]]
|
||||
name = "cm-dashboard"
|
||||
version = "0.1.240"
|
||||
version = "0.1.241"
|
||||
dependencies = [
|
||||
"anyhow",
|
||||
"chrono",
|
||||
@ -301,7 +301,7 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "cm-dashboard-agent"
|
||||
version = "0.1.240"
|
||||
version = "0.1.241"
|
||||
dependencies = [
|
||||
"anyhow",
|
||||
"async-trait",
|
||||
@ -325,7 +325,7 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "cm-dashboard-shared"
|
||||
version = "0.1.240"
|
||||
version = "0.1.241"
|
||||
dependencies = [
|
||||
"chrono",
|
||||
"serde",
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
[package]
|
||||
name = "cm-dashboard-agent"
|
||||
version = "0.1.241"
|
||||
version = "0.1.242"
|
||||
edition = "2021"
|
||||
|
||||
[dependencies]
|
||||
|
||||
@ -152,27 +152,17 @@ impl CpuCollector {
|
||||
/// Extract CPU model number from full model name
|
||||
/// Examples:
|
||||
/// - "Intel(R) Core(TM) i7-9700 CPU @ 3.00GHz" -> "i7-9700"
|
||||
/// - "12th Gen Intel(R) Core(TM) i7-12700K" -> "i7-12700K"
|
||||
/// - "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 Intel Core patterns (both old and new gen): i3, i5, i7, i9
|
||||
// Match pattern like "i7-12700K" or "i7-9700"
|
||||
for prefix in &["i3-", "i5-", "i7-", "i9-"] {
|
||||
if let Some(pos) = full_name.find(prefix) {
|
||||
// Find end of model number (until space or end of string)
|
||||
let after_prefix = &full_name[pos..];
|
||||
let end = after_prefix.find(' ').unwrap_or(after_prefix.len());
|
||||
return after_prefix[..end].to_string();
|
||||
}
|
||||
}
|
||||
|
||||
@ -186,9 +176,9 @@ impl CpuCollector {
|
||||
}
|
||||
}
|
||||
|
||||
// Fallback: return first 20 characters or full name if shorter
|
||||
if full_name.len() > 20 {
|
||||
full_name[..20].to_string()
|
||||
// Fallback: return first 15 characters or full name if shorter
|
||||
if full_name.len() > 15 {
|
||||
full_name[..15].to_string()
|
||||
} else {
|
||||
full_name.to_string()
|
||||
}
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
[package]
|
||||
name = "cm-dashboard"
|
||||
version = "0.1.241"
|
||||
version = "0.1.242"
|
||||
edition = "2021"
|
||||
|
||||
[dependencies]
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
[package]
|
||||
name = "cm-dashboard-shared"
|
||||
version = "0.1.241"
|
||||
version = "0.1.242"
|
||||
edition = "2021"
|
||||
|
||||
[dependencies]
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user