Compare commits
7 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 9d0f42d55c | |||
| 1da7b5f6e7 | |||
| 006f27f7d9 | |||
| 07422cd0a7 | |||
| de30b80219 | |||
| 7d96ca9fad | |||
| 9b940ebd19 |
6
Cargo.lock
generated
6
Cargo.lock
generated
@@ -279,7 +279,7 @@ checksum = "a1d728cc89cf3aee9ff92b05e62b19ee65a02b5702cff7d5a377e32c6ae29d8d"
|
||||
|
||||
[[package]]
|
||||
name = "cm-dashboard"
|
||||
version = "0.1.110"
|
||||
version = "0.1.118"
|
||||
dependencies = [
|
||||
"anyhow",
|
||||
"chrono",
|
||||
@@ -301,7 +301,7 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "cm-dashboard-agent"
|
||||
version = "0.1.110"
|
||||
version = "0.1.118"
|
||||
dependencies = [
|
||||
"anyhow",
|
||||
"async-trait",
|
||||
@@ -324,7 +324,7 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "cm-dashboard-shared"
|
||||
version = "0.1.110"
|
||||
version = "0.1.118"
|
||||
dependencies = [
|
||||
"chrono",
|
||||
"serde",
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
[package]
|
||||
name = "cm-dashboard-agent"
|
||||
version = "0.1.111"
|
||||
version = "0.1.118"
|
||||
edition = "2021"
|
||||
|
||||
[dependencies]
|
||||
|
||||
@@ -119,10 +119,7 @@ impl DiskCollector {
|
||||
let parts: Vec<&str> = line.split_whitespace().collect();
|
||||
if parts.len() >= 2 {
|
||||
let device_name = parts[0]
|
||||
.trim_start_matches('├')
|
||||
.trim_start_matches('└')
|
||||
.trim_start_matches('─')
|
||||
.trim();
|
||||
.trim_start_matches(&['├', '└', '─', ' '][..]);
|
||||
let mount_point = parts[1];
|
||||
|
||||
// Skip unwanted mount points
|
||||
@@ -148,8 +145,13 @@ impl DiskCollector {
|
||||
let mut filesystem_usage = HashMap::new();
|
||||
|
||||
for mount_point in mount_devices.keys() {
|
||||
if let Ok((total, used)) = self.get_filesystem_info(mount_point) {
|
||||
filesystem_usage.insert(mount_point.clone(), (total, used));
|
||||
match self.get_filesystem_info(mount_point) {
|
||||
Ok((total, used)) => {
|
||||
filesystem_usage.insert(mount_point.clone(), (total, used));
|
||||
}
|
||||
Err(e) => {
|
||||
debug!("Failed to get filesystem info for {}: {}", mount_point, e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -693,7 +695,7 @@ impl DiskCollector {
|
||||
value: MetricValue::Float(self.bytes_to_gb(filesystem.used_bytes)),
|
||||
unit: Some("GB".to_string()),
|
||||
description: Some(format!("{}: {}", filesystem.mount_point, self.bytes_to_human_readable(filesystem.used_bytes))),
|
||||
status: Status::Ok,
|
||||
status: fs_status.clone(),
|
||||
timestamp,
|
||||
});
|
||||
|
||||
@@ -702,7 +704,7 @@ impl DiskCollector {
|
||||
value: MetricValue::Float(self.bytes_to_gb(filesystem.total_bytes)),
|
||||
unit: Some("GB".to_string()),
|
||||
description: Some(format!("{}: {}", filesystem.mount_point, self.bytes_to_human_readable(filesystem.total_bytes))),
|
||||
status: Status::Ok,
|
||||
status: fs_status.clone(),
|
||||
timestamp,
|
||||
});
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
[package]
|
||||
name = "cm-dashboard"
|
||||
version = "0.1.111"
|
||||
version = "0.1.118"
|
||||
edition = "2021"
|
||||
|
||||
[dependencies]
|
||||
|
||||
@@ -163,11 +163,7 @@ impl SystemWidget {
|
||||
|
||||
for metric in metrics {
|
||||
if metric.name.starts_with("disk_") {
|
||||
// Wrap individual metric parsing in error handling
|
||||
if let Ok(pool_name) = std::panic::catch_unwind(std::panic::AssertUnwindSafe(|| {
|
||||
self.extract_pool_name(&metric.name)
|
||||
})) {
|
||||
if let Some(pool_name) = pool_name {
|
||||
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(),
|
||||
@@ -184,16 +180,19 @@ impl SystemWidget {
|
||||
});
|
||||
|
||||
// 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 {
|
||||
pool.usage_percent = Some(usage);
|
||||
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 {
|
||||
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 {
|
||||
pool.total_gb = Some(total);
|
||||
}
|
||||
@@ -332,10 +331,7 @@ impl SystemWidget {
|
||||
}
|
||||
}
|
||||
}
|
||||
} // Close pool_name Some check
|
||||
} else {
|
||||
tracing::warn!("Failed to extract pool name from metric: {}", metric.name);
|
||||
} // Close error handling for extract_pool_name
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -357,7 +353,9 @@ impl SystemWidget {
|
||||
// Find the second-to-last underscore to get pool name
|
||||
let before_suffix = &metric_name[..suffix_pos];
|
||||
if let Some(drive_start) = before_suffix.rfind('_') {
|
||||
return Some(metric_name[5..drive_start].to_string()); // Skip "disk_"
|
||||
if drive_start > 5 {
|
||||
return Some(metric_name[5..drive_start].to_string()); // Skip "disk_"
|
||||
}
|
||||
}
|
||||
}
|
||||
// Handle filesystem metrics: disk_{pool}_fs_{filesystem}_{metric}
|
||||
@@ -396,8 +394,11 @@ impl SystemWidget {
|
||||
|
||||
for suffix in known_suffixes {
|
||||
if after_fs.ends_with(suffix) {
|
||||
let fs_name = after_fs[..after_fs.len() - suffix.len() - 1].to_string(); // Remove suffix + underscore
|
||||
return (Some(fs_name), Some(suffix.to_string()));
|
||||
// Extract filesystem name by removing suffix and underscore
|
||||
if let Some(underscore_pos) = after_fs.rfind(&format!("_{}", suffix)) {
|
||||
let fs_name = after_fs[..underscore_pos].to_string();
|
||||
return (Some(fs_name), Some(suffix.to_string()));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -712,13 +713,8 @@ impl Widget for SystemWidget {
|
||||
}
|
||||
}
|
||||
|
||||
// Update storage from all disk metrics (with error handling)
|
||||
if let Err(e) = std::panic::catch_unwind(std::panic::AssertUnwindSafe(|| {
|
||||
self.update_storage_from_metrics(metrics);
|
||||
})) {
|
||||
tracing::error!("Storage metrics parsing failed, continuing with empty storage: {:?}", e);
|
||||
self.storage_pools = Vec::new();
|
||||
}
|
||||
// Update storage from all disk metrics
|
||||
self.update_storage_from_metrics(metrics);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
[package]
|
||||
name = "cm-dashboard-shared"
|
||||
version = "0.1.111"
|
||||
version = "0.1.118"
|
||||
edition = "2021"
|
||||
|
||||
[dependencies]
|
||||
|
||||
Reference in New Issue
Block a user