Fix display format to match CLAUDE.md specification
All checks were successful
Build and Release / build-and-release (push) Successful in 1m17s

- Use actual device names (sdb, sdc) instead of data_0, parity_0
- Fix physical drive naming to show device names instead of mount points
- Update pool name extraction to handle new device-based naming
- Ensure Drive: line shows temperature and wear data for physical drives
This commit is contained in:
Christoffer Martinsson 2025-11-23 18:13:35 +01:00
parent 192eea6e0c
commit 86501fd486
6 changed files with 18 additions and 36 deletions

6
Cargo.lock generated
View File

@ -279,7 +279,7 @@ checksum = "a1d728cc89cf3aee9ff92b05e62b19ee65a02b5702cff7d5a377e32c6ae29d8d"
[[package]]
name = "cm-dashboard"
version = "0.1.124"
version = "0.1.125"
dependencies = [
"anyhow",
"chrono",
@ -301,7 +301,7 @@ dependencies = [
[[package]]
name = "cm-dashboard-agent"
version = "0.1.124"
version = "0.1.125"
dependencies = [
"anyhow",
"async-trait",
@ -324,7 +324,7 @@ dependencies = [
[[package]]
name = "cm-dashboard-shared"
version = "0.1.124"
version = "0.1.125"
dependencies = [
"chrono",
"serde",

View File

@ -1,6 +1,6 @@
[package]
name = "cm-dashboard-agent"
version = "0.1.124"
version = "0.1.125"
edition = "2021"
[dependencies]

View File

@ -905,12 +905,12 @@ impl DiskCollector {
});
// Individual drive metrics
for (i, drive) in pool.data_drives.iter().enumerate() {
self.generate_pool_drive_metrics(metrics, &pool_name, &format!("data_{}", i), drive, timestamp, status_tracker);
for drive in &pool.data_drives {
self.generate_pool_drive_metrics(metrics, &pool_name, &drive.device, drive, timestamp, status_tracker);
}
for (i, drive) in pool.parity_drives.iter().enumerate() {
self.generate_pool_drive_metrics(metrics, &pool_name, &format!("parity_{}", i), drive, timestamp, status_tracker);
for drive in &pool.parity_drives {
self.generate_pool_drive_metrics(metrics, &pool_name, &drive.device, drive, timestamp, status_tracker);
}
}

View File

@ -1,6 +1,6 @@
[package]
name = "cm-dashboard"
version = "0.1.124"
version = "0.1.125"
edition = "2021"
[dependencies]

View File

@ -153,7 +153,9 @@ impl SystemWidget {
"steampool" => "/mnt/steampool".to_string(),
"steampool_1" => "/steampool_1".to_string(),
"steampool_2" => "/steampool_2".to_string(),
_ => format!("/{}", pool_name), // Default fallback
// For device names (nvme0n1, sda, etc.), use the device name directly
name if name.starts_with("nvme") || name.starts_with("sd") || name.starts_with("hd") => name.to_string(),
_ => format!("/{}", pool_name), // Default fallback for mount-based pools
}
}
@ -365,26 +367,13 @@ impl SystemWidget {
.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)
// 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 mergerfs pools, metrics look like: disk_srv_media_data_0_temperature or disk_srv_media_parity_0_temperature
// We need to extract just "srv_media" as the pool name
// 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];
// Check if this looks like a mergerfs drive metric (contains data_ or parity_)
if before_suffix.contains("_data_") {
if let Some(data_pos) = before_suffix.find("_data_") {
return Some(metric_name[5..data_pos].to_string()); // Extract pool name before "_data_"
}
} else if before_suffix.contains("_parity_") {
if let Some(parity_pos) = before_suffix.find("_parity_") {
return Some(metric_name[5..parity_pos].to_string()); // Extract pool name before "_parity_"
}
}
// Fallback for physical drive metrics: find the second-to-last underscore
if let Some(drive_start) = before_suffix.rfind('_') {
if drive_start > 5 {
return Some(metric_name[5..drive_start].to_string()); // Skip "disk_"
@ -429,7 +418,7 @@ impl SystemWidget {
/// Extract drive name from disk metric name
fn extract_drive_name(&self, metric_name: &str) -> Option<String> {
// Pattern: disk_{pool_name}_{drive_name}_{metric_type}
// For mergerfs: disk_{pool_name}_{data|parity}_{index}_{metric_type}
// Now using actual device names like: disk_srv_media_sdb_temperature
// Since pool_name can contain underscores, work backwards from known metric suffixes
if metric_name.starts_with("disk_") {
if let Some(suffix_pos) = metric_name.rfind("_temperature")
@ -437,14 +426,7 @@ impl SystemWidget {
.or_else(|| metric_name.rfind("_health")) {
let before_suffix = &metric_name[..suffix_pos];
// For mergerfs drive metrics: extract the role_index part (e.g., "data_0", "parity_1")
if before_suffix.contains("_data_") || before_suffix.contains("_parity_") {
if let Some(role_start) = before_suffix.rfind("_data_").or_else(|| before_suffix.rfind("_parity_")) {
return Some(before_suffix[role_start + 1..].to_string()); // e.g., "data_0" or "parity_1"
}
}
// Fallback for physical drive metrics: get the last component
// Extract the last component as drive name (e.g., "sdb", "sdc", "nvme0n1")
if let Some(drive_start) = before_suffix.rfind('_') {
return Some(before_suffix[drive_start + 1..].to_string());
}

View File

@ -1,6 +1,6 @@
[package]
name = "cm-dashboard-shared"
version = "0.1.124"
version = "0.1.125"
edition = "2021"
[dependencies]