Compare commits
2 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 67034c84b9 | |||
| c62c7fa698 |
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.224"
|
version = "0.1.226"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"anyhow",
|
"anyhow",
|
||||||
"chrono",
|
"chrono",
|
||||||
@@ -301,7 +301,7 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "cm-dashboard-agent"
|
name = "cm-dashboard-agent"
|
||||||
version = "0.1.224"
|
version = "0.1.226"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"anyhow",
|
"anyhow",
|
||||||
"async-trait",
|
"async-trait",
|
||||||
@@ -325,7 +325,7 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "cm-dashboard-shared"
|
name = "cm-dashboard-shared"
|
||||||
version = "0.1.224"
|
version = "0.1.226"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"chrono",
|
"chrono",
|
||||||
"serde",
|
"serde",
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
[package]
|
[package]
|
||||||
name = "cm-dashboard-agent"
|
name = "cm-dashboard-agent"
|
||||||
version = "0.1.225"
|
version = "0.1.227"
|
||||||
edition = "2021"
|
edition = "2021"
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
|
|||||||
@@ -5,9 +5,7 @@ use cm_dashboard_shared::{AgentData, DriveData, FilesystemData, PoolData, Hyster
|
|||||||
use crate::config::DiskConfig;
|
use crate::config::DiskConfig;
|
||||||
use tokio::process::Command as TokioCommand;
|
use tokio::process::Command as TokioCommand;
|
||||||
use std::process::Command as StdCommand;
|
use std::process::Command as StdCommand;
|
||||||
use std::time::Instant;
|
|
||||||
use std::collections::HashMap;
|
use std::collections::HashMap;
|
||||||
use tracing::debug;
|
|
||||||
|
|
||||||
use super::{Collector, CollectorError};
|
use super::{Collector, CollectorError};
|
||||||
|
|
||||||
@@ -68,9 +66,6 @@ impl DiskCollector {
|
|||||||
|
|
||||||
/// Collect all storage data and populate AgentData
|
/// Collect all storage data and populate AgentData
|
||||||
async fn collect_storage_data(&self, agent_data: &mut AgentData) -> Result<(), CollectorError> {
|
async fn collect_storage_data(&self, agent_data: &mut AgentData) -> Result<(), CollectorError> {
|
||||||
let start_time = Instant::now();
|
|
||||||
debug!("Starting clean storage collection");
|
|
||||||
|
|
||||||
// Step 1: Get mount points and their backing devices
|
// Step 1: Get mount points and their backing devices
|
||||||
let mount_devices = self.get_mount_devices().await?;
|
let mount_devices = self.get_mount_devices().await?;
|
||||||
|
|
||||||
@@ -105,9 +100,6 @@ impl DiskCollector {
|
|||||||
self.populate_drives_data(&physical_drives, &smart_data, agent_data)?;
|
self.populate_drives_data(&physical_drives, &smart_data, agent_data)?;
|
||||||
self.populate_pools_data(&mergerfs_pools, &smart_data, agent_data)?;
|
self.populate_pools_data(&mergerfs_pools, &smart_data, agent_data)?;
|
||||||
|
|
||||||
let elapsed = start_time.elapsed();
|
|
||||||
debug!("Storage collection completed in {:?}", elapsed);
|
|
||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -142,7 +134,6 @@ impl DiskCollector {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
debug!("Found {} mounted block devices", mount_devices.len());
|
|
||||||
Ok(mount_devices)
|
Ok(mount_devices)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -155,8 +146,8 @@ impl DiskCollector {
|
|||||||
Ok((total, used)) => {
|
Ok((total, used)) => {
|
||||||
filesystem_usage.insert(mount_point.clone(), (total, used));
|
filesystem_usage.insert(mount_point.clone(), (total, used));
|
||||||
}
|
}
|
||||||
Err(e) => {
|
Err(_e) => {
|
||||||
debug!("Failed to get filesystem info for {}: {}", mount_point, e);
|
// Silently skip filesystems we can't read
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -177,8 +168,6 @@ impl DiskCollector {
|
|||||||
// Only add if we don't already have usage data for this mount point
|
// Only add if we don't already have usage data for this mount point
|
||||||
if !filesystem_usage.contains_key(&mount_point) {
|
if !filesystem_usage.contains_key(&mount_point) {
|
||||||
if let Ok((total, used)) = self.get_filesystem_info(&mount_point) {
|
if let Ok((total, used)) = self.get_filesystem_info(&mount_point) {
|
||||||
debug!("Added MergerFS filesystem usage for {}: {}GB total, {}GB used",
|
|
||||||
mount_point, total as f32 / (1024.0 * 1024.0 * 1024.0), used as f32 / (1024.0 * 1024.0 * 1024.0));
|
|
||||||
filesystem_usage.insert(mount_point, (total, used));
|
filesystem_usage.insert(mount_point, (total, used));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -253,9 +242,8 @@ impl DiskCollector {
|
|||||||
} else {
|
} else {
|
||||||
mount_point.trim_start_matches('/').replace('/', "_")
|
mount_point.trim_start_matches('/').replace('/', "_")
|
||||||
};
|
};
|
||||||
|
|
||||||
if pool_name.is_empty() {
|
if pool_name.is_empty() {
|
||||||
debug!("Skipping mergerfs pool with empty name: {}", mount_point);
|
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -283,8 +271,7 @@ impl DiskCollector {
|
|||||||
// Categorize as data vs parity drives
|
// Categorize as data vs parity drives
|
||||||
let (data_drives, parity_drives) = match self.categorize_pool_drives(&all_member_paths) {
|
let (data_drives, parity_drives) = match self.categorize_pool_drives(&all_member_paths) {
|
||||||
Ok(drives) => drives,
|
Ok(drives) => drives,
|
||||||
Err(e) => {
|
Err(_e) => {
|
||||||
debug!("Failed to categorize drives for pool {}: {}. Skipping.", mount_point, e);
|
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
@@ -299,8 +286,7 @@ impl DiskCollector {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
debug!("Found {} mergerfs pools", pools.len());
|
|
||||||
Ok(pools)
|
Ok(pools)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
[package]
|
[package]
|
||||||
name = "cm-dashboard"
|
name = "cm-dashboard"
|
||||||
version = "0.1.225"
|
version = "0.1.227"
|
||||||
edition = "2021"
|
edition = "2021"
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
|
|||||||
@@ -11,6 +11,59 @@ use tracing::debug;
|
|||||||
use crate::ui::theme::{Components, StatusIcons, Theme, Typography};
|
use crate::ui::theme::{Components, StatusIcons, Theme, Typography};
|
||||||
use ratatui::style::Style;
|
use ratatui::style::Style;
|
||||||
|
|
||||||
|
/// Column visibility configuration based on terminal width
|
||||||
|
#[derive(Debug, Clone, Copy)]
|
||||||
|
struct ColumnVisibility {
|
||||||
|
show_name: bool,
|
||||||
|
show_status: bool,
|
||||||
|
show_ram: bool,
|
||||||
|
show_uptime: bool,
|
||||||
|
show_restarts: bool,
|
||||||
|
}
|
||||||
|
|
||||||
|
impl ColumnVisibility {
|
||||||
|
/// Determine which columns to show based on available width
|
||||||
|
fn from_width(width: u16) -> Self {
|
||||||
|
if width >= 80 {
|
||||||
|
// Full layout: Name (25) + Status (10) + RAM (8) + Uptime (8) + Restarts (5) = 56 chars
|
||||||
|
Self {
|
||||||
|
show_name: true,
|
||||||
|
show_status: true,
|
||||||
|
show_ram: true,
|
||||||
|
show_uptime: true,
|
||||||
|
show_restarts: true,
|
||||||
|
}
|
||||||
|
} else if width >= 60 {
|
||||||
|
// Hide restarts: Name (25) + Status (10) + RAM (8) + Uptime (8) = 51 chars
|
||||||
|
Self {
|
||||||
|
show_name: true,
|
||||||
|
show_status: true,
|
||||||
|
show_ram: true,
|
||||||
|
show_uptime: true,
|
||||||
|
show_restarts: false,
|
||||||
|
}
|
||||||
|
} else if width >= 45 {
|
||||||
|
// Hide uptime and restarts: Name (25) + Status (10) + RAM (8) = 43 chars
|
||||||
|
Self {
|
||||||
|
show_name: true,
|
||||||
|
show_status: true,
|
||||||
|
show_ram: true,
|
||||||
|
show_uptime: false,
|
||||||
|
show_restarts: false,
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
// Minimal: Name (25) + Status (10) = 35 chars
|
||||||
|
Self {
|
||||||
|
show_name: true,
|
||||||
|
show_status: true,
|
||||||
|
show_ram: false,
|
||||||
|
show_uptime: false,
|
||||||
|
show_restarts: false,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/// Services widget displaying hierarchical systemd service statuses
|
/// Services widget displaying hierarchical systemd service statuses
|
||||||
#[derive(Clone)]
|
#[derive(Clone)]
|
||||||
pub struct ServicesWidget {
|
pub struct ServicesWidget {
|
||||||
@@ -76,7 +129,7 @@ impl ServicesWidget {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// Format parent service line - returns text without icon for span formatting
|
/// Format parent service line - returns text without icon for span formatting
|
||||||
fn format_parent_service_line(&self, name: &str, info: &ServiceInfo) -> String {
|
fn format_parent_service_line(&self, name: &str, info: &ServiceInfo, columns: ColumnVisibility) -> String {
|
||||||
// Truncate long service names to fit layout (account for icon space)
|
// Truncate long service names to fit layout (account for icon space)
|
||||||
let short_name = if name.len() > 22 {
|
let short_name = if name.len() > 22 {
|
||||||
format!("{}...", &name[..19])
|
format!("{}...", &name[..19])
|
||||||
@@ -129,10 +182,25 @@ impl ServicesWidget {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
format!(
|
// Build format string based on column visibility
|
||||||
"{:<23} {:<10} {:<8} {:<8} {:<5}",
|
let mut parts = Vec::new();
|
||||||
short_name, status_str, memory_str, uptime_str, restart_str
|
if columns.show_name {
|
||||||
)
|
parts.push(format!("{:<23}", short_name));
|
||||||
|
}
|
||||||
|
if columns.show_status {
|
||||||
|
parts.push(format!("{:<10}", status_str));
|
||||||
|
}
|
||||||
|
if columns.show_ram {
|
||||||
|
parts.push(format!("{:<8}", memory_str));
|
||||||
|
}
|
||||||
|
if columns.show_uptime {
|
||||||
|
parts.push(format!("{:<8}", uptime_str));
|
||||||
|
}
|
||||||
|
if columns.show_restarts {
|
||||||
|
parts.push(format!("{:<5}", restart_str));
|
||||||
|
}
|
||||||
|
|
||||||
|
parts.join(" ")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -476,11 +544,28 @@ impl ServicesWidget {
|
|||||||
.constraints([Constraint::Length(1), Constraint::Min(0)])
|
.constraints([Constraint::Length(1), Constraint::Min(0)])
|
||||||
.split(inner_area);
|
.split(inner_area);
|
||||||
|
|
||||||
// Header
|
// Determine which columns to show based on available width
|
||||||
let header = format!(
|
let columns = ColumnVisibility::from_width(inner_area.width);
|
||||||
"{:<25} {:<10} {:<8} {:<8} {:<5}",
|
|
||||||
"Service:", "Status:", "RAM:", "Uptime:", "↻:"
|
// Build header based on visible columns
|
||||||
);
|
let mut header_parts = Vec::new();
|
||||||
|
if columns.show_name {
|
||||||
|
header_parts.push(format!("{:<25}", "Service:"));
|
||||||
|
}
|
||||||
|
if columns.show_status {
|
||||||
|
header_parts.push(format!("{:<10}", "Status:"));
|
||||||
|
}
|
||||||
|
if columns.show_ram {
|
||||||
|
header_parts.push(format!("{:<8}", "RAM:"));
|
||||||
|
}
|
||||||
|
if columns.show_uptime {
|
||||||
|
header_parts.push(format!("{:<8}", "Uptime:"));
|
||||||
|
}
|
||||||
|
if columns.show_restarts {
|
||||||
|
header_parts.push(format!("{:<5}", "↻:"));
|
||||||
|
}
|
||||||
|
let header = header_parts.join(" ");
|
||||||
|
|
||||||
let header_para = Paragraph::new(header).style(Typography::muted());
|
let header_para = Paragraph::new(header).style(Typography::muted());
|
||||||
frame.render_widget(header_para, content_chunks[0]);
|
frame.render_widget(header_para, content_chunks[0]);
|
||||||
|
|
||||||
@@ -492,11 +577,11 @@ impl ServicesWidget {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Render the services list
|
// Render the services list
|
||||||
self.render_services(frame, content_chunks[1], is_focused);
|
self.render_services(frame, content_chunks[1], is_focused, columns);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Render services list
|
/// Render services list
|
||||||
fn render_services(&mut self, frame: &mut Frame, area: Rect, is_focused: bool) {
|
fn render_services(&mut self, frame: &mut Frame, area: Rect, is_focused: bool, columns: ColumnVisibility) {
|
||||||
// Build hierarchical service list for display
|
// Build hierarchical service list for display
|
||||||
let mut display_lines: Vec<(String, Status, bool, Option<(ServiceInfo, bool)>)> = Vec::new();
|
let mut display_lines: Vec<(String, Status, bool, Option<(ServiceInfo, bool)>)> = Vec::new();
|
||||||
|
|
||||||
@@ -506,7 +591,7 @@ impl ServicesWidget {
|
|||||||
|
|
||||||
for (parent_name, parent_info) in parent_services {
|
for (parent_name, parent_info) in parent_services {
|
||||||
// Add parent service line
|
// Add parent service line
|
||||||
let parent_line = self.format_parent_service_line(parent_name, parent_info);
|
let parent_line = self.format_parent_service_line(parent_name, parent_info, columns);
|
||||||
display_lines.push((parent_line, parent_info.widget_status, false, None));
|
display_lines.push((parent_line, parent_info.widget_status, false, None));
|
||||||
|
|
||||||
// Add sub-services for this parent (if any)
|
// Add sub-services for this parent (if any)
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
[package]
|
[package]
|
||||||
name = "cm-dashboard-shared"
|
name = "cm-dashboard-shared"
|
||||||
version = "0.1.225"
|
version = "0.1.227"
|
||||||
edition = "2021"
|
edition = "2021"
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
|
|||||||
Reference in New Issue
Block a user