Compare commits

..

4 Commits

Author SHA1 Message Date
9d0f42d55c Fix filesystem usage_percent parsing and remove hardcoded status
All checks were successful
Build and Release / build-and-release (push) Successful in 1m8s
1. Add missing _fs_ filter to usage_percent parsing in dashboard
2. Fix agent to use calculated fs_status instead of hardcoded Status::Ok

This completes the disk collector auto-discovery by ensuring filesystem
usage percentages and status indicators display correctly.
2025-11-23 16:47:20 +01:00
1da7b5f6e7 Fix both pool-level and filesystem metric parsing bugs
All checks were successful
Build and Release / build-and-release (push) Successful in 1m10s
1. Prevent filesystem _fs_ metrics from overwriting pool totals
2. Fix filesystem name extraction to properly parse boot/root names

This resolves both the pool total display (showing 0.1GB instead of 220GB)
and individual filesystem display (showing —% —GB/—GB).
2025-11-23 16:29:00 +01:00
006f27f7d9 Fix lsblk parsing for filesystem discovery
All checks were successful
Build and Release / build-and-release (push) Successful in 1m9s
Remove unused debug code and fix device name parsing to properly
handle lsblk tree characters. This resolves the issue where only
/boot filesystem was discovered instead of both /boot and /.
2025-11-23 16:09:48 +01:00
07422cd0a7 Add debug logging for filesystem discovery
All checks were successful
Build and Release / build-and-release (push) Successful in 1m18s
2025-11-23 15:26:49 +01:00
6 changed files with 18 additions and 19 deletions

6
Cargo.lock generated
View File

@@ -279,7 +279,7 @@ checksum = "a1d728cc89cf3aee9ff92b05e62b19ee65a02b5702cff7d5a377e32c6ae29d8d"
[[package]] [[package]]
name = "cm-dashboard" name = "cm-dashboard"
version = "0.1.114" version = "0.1.118"
dependencies = [ dependencies = [
"anyhow", "anyhow",
"chrono", "chrono",
@@ -301,7 +301,7 @@ dependencies = [
[[package]] [[package]]
name = "cm-dashboard-agent" name = "cm-dashboard-agent"
version = "0.1.114" version = "0.1.118"
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.114" version = "0.1.118"
dependencies = [ dependencies = [
"chrono", "chrono",
"serde", "serde",

View File

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

View File

@@ -119,10 +119,7 @@ impl DiskCollector {
let parts: Vec<&str> = line.split_whitespace().collect(); let parts: Vec<&str> = line.split_whitespace().collect();
if parts.len() >= 2 { if parts.len() >= 2 {
let device_name = parts[0] let device_name = parts[0]
.trim_start_matches('├') .trim_start_matches(&['├', '└', '─', ' '][..]);
.trim_start_matches('└')
.trim_start_matches('─')
.trim();
let mount_point = parts[1]; let mount_point = parts[1];
// Skip unwanted mount points // Skip unwanted mount points
@@ -698,7 +695,7 @@ impl DiskCollector {
value: MetricValue::Float(self.bytes_to_gb(filesystem.used_bytes)), value: MetricValue::Float(self.bytes_to_gb(filesystem.used_bytes)),
unit: Some("GB".to_string()), unit: Some("GB".to_string()),
description: Some(format!("{}: {}", filesystem.mount_point, self.bytes_to_human_readable(filesystem.used_bytes))), description: Some(format!("{}: {}", filesystem.mount_point, self.bytes_to_human_readable(filesystem.used_bytes))),
status: Status::Ok, status: fs_status.clone(),
timestamp, timestamp,
}); });
@@ -707,7 +704,7 @@ impl DiskCollector {
value: MetricValue::Float(self.bytes_to_gb(filesystem.total_bytes)), value: MetricValue::Float(self.bytes_to_gb(filesystem.total_bytes)),
unit: Some("GB".to_string()), unit: Some("GB".to_string()),
description: Some(format!("{}: {}", filesystem.mount_point, self.bytes_to_human_readable(filesystem.total_bytes))), description: Some(format!("{}: {}", filesystem.mount_point, self.bytes_to_human_readable(filesystem.total_bytes))),
status: Status::Ok, status: fs_status.clone(),
timestamp, timestamp,
}); });

View File

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

View File

@@ -180,16 +180,19 @@ impl SystemWidget {
}); });
// Parse different metric types // Parse different metric types
if metric.name.contains("_usage_percent") { if metric.name.contains("_usage_percent") && !metric.name.contains("_fs_") {
// Only use drive-level metrics for pool totals, not filesystem metrics
if let MetricValue::Float(usage) = metric.value { if let MetricValue::Float(usage) = metric.value {
pool.usage_percent = Some(usage); pool.usage_percent = Some(usage);
pool.status = metric.status.clone(); pool.status = metric.status.clone();
} }
} else if metric.name.contains("_used_gb") { } else if metric.name.contains("_used_gb") && !metric.name.contains("_fs_") {
// Only use drive-level metrics for pool totals, not filesystem metrics
if let MetricValue::Float(used) = metric.value { if let MetricValue::Float(used) = metric.value {
pool.used_gb = Some(used); pool.used_gb = Some(used);
} }
} else if metric.name.contains("_total_gb") { } else if metric.name.contains("_total_gb") && !metric.name.contains("_fs_") {
// Only use drive-level metrics for pool totals, not filesystem metrics
if let MetricValue::Float(total) = metric.value { if let MetricValue::Float(total) = metric.value {
pool.total_gb = Some(total); pool.total_gb = Some(total);
} }
@@ -391,10 +394,9 @@ impl SystemWidget {
for suffix in known_suffixes { for suffix in known_suffixes {
if after_fs.ends_with(suffix) { if after_fs.ends_with(suffix) {
// Safely calculate fs_name length // Extract filesystem name by removing suffix and underscore
let suffix_with_underscore = suffix.len() + 1; if let Some(underscore_pos) = after_fs.rfind(&format!("_{}", suffix)) {
if after_fs.len() > suffix_with_underscore { let fs_name = after_fs[..underscore_pos].to_string();
let fs_name = after_fs[..after_fs.len() - suffix_with_underscore].to_string();
return (Some(fs_name), Some(suffix.to_string())); return (Some(fs_name), Some(suffix.to_string()));
} }
} }

View File

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