Fix mergerfs pool consolidation and naming
All checks were successful
Build and Release / build-and-release (push) Successful in 1m18s
All checks were successful
Build and Release / build-and-release (push) Successful in 1m18s
- Improve pool name extraction in dashboard parsing - Use consistent mergerfs pool naming in agent - Add mount_point metric parsing to use actual mount paths - Fix pool consolidation to prevent duplicate entries
This commit is contained in:
parent
439d0d9af6
commit
e47803b705
6
Cargo.lock
generated
6
Cargo.lock
generated
@ -279,7 +279,7 @@ checksum = "a1d728cc89cf3aee9ff92b05e62b19ee65a02b5702cff7d5a377e32c6ae29d8d"
|
||||
|
||||
[[package]]
|
||||
name = "cm-dashboard"
|
||||
version = "0.1.120"
|
||||
version = "0.1.121"
|
||||
dependencies = [
|
||||
"anyhow",
|
||||
"chrono",
|
||||
@ -301,7 +301,7 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "cm-dashboard-agent"
|
||||
version = "0.1.120"
|
||||
version = "0.1.121"
|
||||
dependencies = [
|
||||
"anyhow",
|
||||
"async-trait",
|
||||
@ -324,7 +324,7 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "cm-dashboard-shared"
|
||||
version = "0.1.120"
|
||||
version = "0.1.121"
|
||||
dependencies = [
|
||||
"chrono",
|
||||
"serde",
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
[package]
|
||||
name = "cm-dashboard-agent"
|
||||
version = "0.1.120"
|
||||
version = "0.1.121"
|
||||
edition = "2021"
|
||||
|
||||
[dependencies]
|
||||
|
||||
@ -781,7 +781,13 @@ impl DiskCollector {
|
||||
timestamp: u64,
|
||||
status_tracker: &mut StatusTracker
|
||||
) {
|
||||
let pool_name = pool.mount_point.trim_start_matches('/').replace('/', "_");
|
||||
// Use consistent pool naming: extract mount point without leading slash
|
||||
let pool_name = if pool.mount_point == "/" {
|
||||
"root".to_string()
|
||||
} else {
|
||||
pool.mount_point.trim_start_matches('/').replace('/', "_")
|
||||
};
|
||||
|
||||
if pool_name.is_empty() {
|
||||
return;
|
||||
}
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
[package]
|
||||
name = "cm-dashboard"
|
||||
version = "0.1.120"
|
||||
version = "0.1.121"
|
||||
edition = "2021"
|
||||
|
||||
[dependencies]
|
||||
|
||||
@ -164,10 +164,9 @@ impl SystemWidget {
|
||||
for metric in metrics {
|
||||
if metric.name.starts_with("disk_") {
|
||||
if let Some(pool_name) = self.extract_pool_name(&metric.name) {
|
||||
let mount_point = self.get_mount_point_for_pool(&pool_name);
|
||||
let pool = pools.entry(pool_name.clone()).or_insert_with(|| StoragePool {
|
||||
name: pool_name.clone(),
|
||||
mount_point: mount_point.clone(),
|
||||
mount_point: self.get_mount_point_for_pool(&pool_name), // Default fallback
|
||||
pool_type: "single".to_string(), // Default, will be updated
|
||||
pool_health: None,
|
||||
drives: Vec::new(),
|
||||
@ -196,6 +195,10 @@ impl SystemWidget {
|
||||
if let MetricValue::Float(total) = metric.value {
|
||||
pool.total_gb = Some(total);
|
||||
}
|
||||
} else if metric.name.contains("_mount_point") {
|
||||
if let MetricValue::String(mount_point) = &metric.value {
|
||||
pool.mount_point = mount_point.clone();
|
||||
}
|
||||
} else if metric.name.contains("_pool_type") {
|
||||
if let MetricValue::String(pool_type) = &metric.value {
|
||||
pool.pool_type = pool_type.clone();
|
||||
@ -343,11 +346,27 @@ impl SystemWidget {
|
||||
|
||||
/// Extract pool name from disk metric name
|
||||
fn extract_pool_name(&self, metric_name: &str) -> Option<String> {
|
||||
// Pattern: disk_{pool_name}_{drive_name}_{metric_type}
|
||||
// Pattern: disk_{pool_name}_{various suffixes}
|
||||
// Since pool_name can contain underscores, work backwards from known metric suffixes
|
||||
if metric_name.starts_with("disk_") {
|
||||
// First try drive-specific metrics that have device names
|
||||
if let Some(suffix_pos) = metric_name.rfind("_temperature")
|
||||
// Handle filesystem metrics: disk_{pool}_fs_{filesystem}_{metric}
|
||||
if metric_name.contains("_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_"
|
||||
}
|
||||
}
|
||||
// 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")
|
||||
.or_else(|| metric_name.rfind("_used_gb"))
|
||||
.or_else(|| metric_name.rfind("_total_gb"))
|
||||
.or_else(|| metric_name.rfind("_available_gb"))
|
||||
.or_else(|| metric_name.rfind("_mount_point"))
|
||||
.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_role}_{metric} (for mergerfs) or disk_{pool}_{drive}_{metric} (for physical drives)
|
||||
else if let Some(suffix_pos) = metric_name.rfind("_temperature")
|
||||
.or_else(|| metric_name.rfind("_wear_percent"))
|
||||
.or_else(|| metric_name.rfind("_health")) {
|
||||
// Find the second-to-last underscore to get pool name
|
||||
@ -358,20 +377,7 @@ impl SystemWidget {
|
||||
}
|
||||
}
|
||||
}
|
||||
// Handle filesystem metrics: disk_{pool}_fs_{filesystem}_{metric}
|
||||
else if metric_name.contains("_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_"
|
||||
}
|
||||
}
|
||||
// For pool-level metrics (usage_percent, used_gb, total_gb), take everything before the metric suffix
|
||||
else if let Some(suffix_pos) = metric_name.rfind("_usage_percent")
|
||||
.or_else(|| metric_name.rfind("_used_gb"))
|
||||
.or_else(|| metric_name.rfind("_total_gb"))
|
||||
.or_else(|| metric_name.rfind("_available_gb")) {
|
||||
return Some(metric_name[5..suffix_pos].to_string()); // Skip "disk_"
|
||||
}
|
||||
// Fallback to old behavior for unknown patterns
|
||||
// Fallback: extract first component after disk_ prefix
|
||||
else if let Some(captures) = metric_name.strip_prefix("disk_") {
|
||||
if let Some(pos) = captures.find('_') {
|
||||
return Some(captures[..pos].to_string());
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
[package]
|
||||
name = "cm-dashboard-shared"
|
||||
version = "0.1.120"
|
||||
version = "0.1.121"
|
||||
edition = "2021"
|
||||
|
||||
[dependencies]
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user