Fix pool name extraction to prevent wrong physical drive naming
All checks were successful
Build and Release / build-and-release (push) Successful in 2m10s
All checks were successful
Build and Release / build-and-release (push) Successful in 2m10s
- Remove fallback logic that could extract incorrect pool names - Simplify pool suffix matching to use explicit arrays - Ensure only valid metric patterns create pools
This commit is contained in:
parent
86501fd486
commit
f24c4ed650
6
Cargo.lock
generated
6
Cargo.lock
generated
@ -279,7 +279,7 @@ checksum = "a1d728cc89cf3aee9ff92b05e62b19ee65a02b5702cff7d5a377e32c6ae29d8d"
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "cm-dashboard"
|
name = "cm-dashboard"
|
||||||
version = "0.1.125"
|
version = "0.1.126"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"anyhow",
|
"anyhow",
|
||||||
"chrono",
|
"chrono",
|
||||||
@ -301,7 +301,7 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "cm-dashboard-agent"
|
name = "cm-dashboard-agent"
|
||||||
version = "0.1.125"
|
version = "0.1.126"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"anyhow",
|
"anyhow",
|
||||||
"async-trait",
|
"async-trait",
|
||||||
@ -324,7 +324,7 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "cm-dashboard-shared"
|
name = "cm-dashboard-shared"
|
||||||
version = "0.1.125"
|
version = "0.1.126"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"chrono",
|
"chrono",
|
||||||
"serde",
|
"serde",
|
||||||
|
|||||||
@ -1,6 +1,6 @@
|
|||||||
[package]
|
[package]
|
||||||
name = "cm-dashboard-agent"
|
name = "cm-dashboard-agent"
|
||||||
version = "0.1.125"
|
version = "0.1.126"
|
||||||
edition = "2021"
|
edition = "2021"
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
|
|||||||
@ -1,6 +1,6 @@
|
|||||||
[package]
|
[package]
|
||||||
name = "cm-dashboard"
|
name = "cm-dashboard"
|
||||||
version = "0.1.125"
|
version = "0.1.126"
|
||||||
edition = "2021"
|
edition = "2021"
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
|
|||||||
@ -351,39 +351,33 @@ impl SystemWidget {
|
|||||||
// Pattern: disk_{pool_name}_{various suffixes}
|
// Pattern: disk_{pool_name}_{various suffixes}
|
||||||
// Since pool_name can contain underscores, work backwards from known metric suffixes
|
// Since pool_name can contain underscores, work backwards from known metric suffixes
|
||||||
if metric_name.starts_with("disk_") {
|
if metric_name.starts_with("disk_") {
|
||||||
// Handle filesystem metrics: disk_{pool}_fs_{filesystem}_{metric}
|
// Handle filesystem metrics: disk_{pool}_fs_{filesystem}_{metric}
|
||||||
if metric_name.contains("_fs_") {
|
if metric_name.contains("_fs_") {
|
||||||
if let Some(fs_pos) = metric_name.find("_fs_") {
|
if let Some(fs_pos) = metric_name.find("_fs_") {
|
||||||
return Some(metric_name[5..fs_pos].to_string()); // Skip "disk_", extract pool name before "_fs_"
|
return Some(metric_name[5..fs_pos].to_string()); // Skip "disk_", extract pool name before "_fs_"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Handle pool-level metrics (usage_percent, used_gb, total_gb, mount_point, pool_type, pool_health)
|
// Handle pool-level metrics (usage_percent, used_gb, total_gb, mount_point, pool_type, pool_health)
|
||||||
else if let Some(suffix_pos) = metric_name.rfind("_usage_percent")
|
// Use rfind to get the last occurrence of these suffixes
|
||||||
.or_else(|| metric_name.rfind("_used_gb"))
|
let pool_suffixes = ["_usage_percent", "_used_gb", "_total_gb", "_available_gb", "_mount_point", "_pool_type", "_pool_health"];
|
||||||
.or_else(|| metric_name.rfind("_total_gb"))
|
for suffix in pool_suffixes {
|
||||||
.or_else(|| metric_name.rfind("_available_gb"))
|
if let Some(suffix_pos) = metric_name.rfind(suffix) {
|
||||||
.or_else(|| metric_name.rfind("_mount_point"))
|
return Some(metric_name[5..suffix_pos].to_string()); // Skip "disk_"
|
||||||
.or_else(|| metric_name.rfind("_pool_type"))
|
|
||||||
.or_else(|| metric_name.rfind("_pool_health")) {
|
|
||||||
return Some(metric_name[5..suffix_pos].to_string()); // Skip "disk_"
|
|
||||||
}
|
|
||||||
// Handle drive-specific metrics: disk_{pool}_{drive}_{metric}
|
|
||||||
else if let Some(suffix_pos) = metric_name.rfind("_temperature")
|
|
||||||
.or_else(|| metric_name.rfind("_wear_percent"))
|
|
||||||
.or_else(|| metric_name.rfind("_health")) {
|
|
||||||
// For both mergerfs and physical drives: disk_{pool_name}_{drive_name}_{metric}
|
|
||||||
// Extract pool name by finding the second-to-last underscore
|
|
||||||
let before_suffix = &metric_name[..suffix_pos];
|
|
||||||
if let Some(drive_start) = before_suffix.rfind('_') {
|
|
||||||
if drive_start > 5 {
|
|
||||||
return Some(metric_name[5..drive_start].to_string()); // Skip "disk_"
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// Fallback: extract first component after disk_ prefix
|
|
||||||
else if let Some(captures) = metric_name.strip_prefix("disk_") {
|
// Handle drive-specific metrics: disk_{pool}_{drive}_{metric}
|
||||||
if let Some(pos) = captures.find('_') {
|
let drive_suffixes = ["_temperature", "_wear_percent", "_health"];
|
||||||
return Some(captures[..pos].to_string());
|
for suffix in drive_suffixes {
|
||||||
|
if let Some(suffix_pos) = metric_name.rfind(suffix) {
|
||||||
|
// Extract pool name by finding the second-to-last underscore
|
||||||
|
let before_suffix = &metric_name[..suffix_pos];
|
||||||
|
if let Some(drive_start) = before_suffix.rfind('_') {
|
||||||
|
if drive_start > 5 {
|
||||||
|
return Some(metric_name[5..drive_start].to_string()); // Skip "disk_"
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,6 +1,6 @@
|
|||||||
[package]
|
[package]
|
||||||
name = "cm-dashboard-shared"
|
name = "cm-dashboard-shared"
|
||||||
version = "0.1.125"
|
version = "0.1.126"
|
||||||
edition = "2021"
|
edition = "2021"
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user