Implement real-time process monitoring and fix UI hardcoded data
This commit addresses several key issues identified during development: Major Changes: - Replace hardcoded top CPU/RAM process display with real system data - Add intelligent process monitoring to CpuCollector using ps command - Fix disk metrics permission issues in systemd collector - Optimize service collection to focus on status, memory, and disk only - Update dashboard widgets to display live process information Process Monitoring Implementation: - Added collect_top_cpu_process() and collect_top_ram_process() methods - Implemented ps-based monitoring with accurate CPU percentages - Added filtering to prevent self-monitoring artifacts (ps commands) - Enhanced error handling and validation for process data - Dashboard now shows realistic values like "claude (PID 2974) 11.0%" Service Collection Optimization: - Removed CPU monitoring from systemd collector for efficiency - Enhanced service directory permission error logging - Simplified services widget to show essential metrics only - Fixed service-to-directory mapping accuracy UI and Dashboard Improvements: - Reorganized dashboard layout with btop-inspired multi-panel design - Updated system panel to include real top CPU/RAM process display - Enhanced widget formatting and data presentation - Removed placeholder/hardcoded data throughout the interface Technical Details: - Updated agent/src/collectors/cpu.rs with process monitoring - Modified dashboard/src/ui/mod.rs for real-time process display - Enhanced systemd collector error handling and disk metrics - Updated CLAUDE.md documentation with implementation details
This commit is contained in:
134
dashboard/src/ui/theme.rs
Normal file
134
dashboard/src/ui/theme.rs
Normal file
@@ -0,0 +1,134 @@
|
||||
use ratatui::style::{Color, Style, Modifier};
|
||||
use cm_dashboard_shared::Status;
|
||||
|
||||
/// Color theme for the dashboard - btop dark theme
|
||||
pub struct Theme;
|
||||
|
||||
impl Theme {
|
||||
/// Get color for status level (btop-style)
|
||||
pub fn status_color(status: Status) -> Color {
|
||||
match status {
|
||||
Status::Ok => Self::success(),
|
||||
Status::Warning => Self::warning(),
|
||||
Status::Critical => Self::error(),
|
||||
Status::Unknown => Self::muted_text(),
|
||||
}
|
||||
}
|
||||
|
||||
/// Get style for status level
|
||||
pub fn status_style(status: Status) -> Style {
|
||||
Style::default().fg(Self::status_color(status))
|
||||
}
|
||||
|
||||
/// Primary text color (btop bright text)
|
||||
pub fn primary_text() -> Color {
|
||||
Color::Rgb(255, 255, 255) // Pure white
|
||||
}
|
||||
|
||||
/// Secondary text color (btop muted text)
|
||||
pub fn secondary_text() -> Color {
|
||||
Color::Rgb(180, 180, 180) // Light gray
|
||||
}
|
||||
|
||||
/// Muted text color (btop dimmed text)
|
||||
pub fn muted_text() -> Color {
|
||||
Color::Rgb(120, 120, 120) // Medium gray
|
||||
}
|
||||
|
||||
/// Border color (btop muted borders)
|
||||
pub fn border() -> Color {
|
||||
Color::Rgb(100, 100, 100) // Muted gray like btop
|
||||
}
|
||||
|
||||
/// Secondary border color (btop blue)
|
||||
pub fn border_secondary() -> Color {
|
||||
Color::Rgb(100, 149, 237) // Cornflower blue
|
||||
}
|
||||
|
||||
/// Background color (btop true black)
|
||||
pub fn background() -> Color {
|
||||
Color::Black // True black like btop
|
||||
}
|
||||
|
||||
/// Highlight color (btop selection)
|
||||
pub fn highlight() -> Color {
|
||||
Color::Rgb(58, 150, 221) // Bright blue
|
||||
}
|
||||
|
||||
/// Success color (btop green)
|
||||
pub fn success() -> Color {
|
||||
Color::Rgb(40, 167, 69) // Success green
|
||||
}
|
||||
|
||||
/// Warning color (btop orange/yellow)
|
||||
pub fn warning() -> Color {
|
||||
Color::Rgb(255, 193, 7) // Warning amber
|
||||
}
|
||||
|
||||
/// Error color (btop red)
|
||||
pub fn error() -> Color {
|
||||
Color::Rgb(220, 53, 69) // Error red
|
||||
}
|
||||
|
||||
/// Info color (btop blue)
|
||||
pub fn info() -> Color {
|
||||
Color::Rgb(23, 162, 184) // Info cyan-blue
|
||||
}
|
||||
|
||||
/// CPU usage colors (btop CPU gradient)
|
||||
pub fn cpu_color(percentage: u16) -> Color {
|
||||
match percentage {
|
||||
0..=25 => Color::Rgb(46, 160, 67), // Green
|
||||
26..=50 => Color::Rgb(255, 206, 84), // Yellow
|
||||
51..=75 => Color::Rgb(255, 159, 67), // Orange
|
||||
76..=100 => Color::Rgb(255, 69, 58), // Red
|
||||
_ => Color::Rgb(255, 69, 58), // Red for >100%
|
||||
}
|
||||
}
|
||||
|
||||
/// Memory usage colors (btop memory gradient)
|
||||
pub fn memory_color(percentage: u16) -> Color {
|
||||
match percentage {
|
||||
0..=60 => Color::Rgb(52, 199, 89), // Green
|
||||
61..=80 => Color::Rgb(255, 214, 10), // Yellow
|
||||
81..=95 => Color::Rgb(255, 149, 0), // Orange
|
||||
96..=100 => Color::Rgb(255, 59, 48), // Red
|
||||
_ => Color::Rgb(255, 59, 48), // Red for >100%
|
||||
}
|
||||
}
|
||||
|
||||
/// Get gauge color based on percentage (btop-style gradient)
|
||||
pub fn gauge_color(percentage: u16, warning_threshold: u16, critical_threshold: u16) -> Color {
|
||||
if percentage >= critical_threshold {
|
||||
Self::error()
|
||||
} else if percentage >= warning_threshold {
|
||||
Self::warning()
|
||||
} else {
|
||||
Self::success()
|
||||
}
|
||||
}
|
||||
|
||||
/// Title style (btop widget titles)
|
||||
pub fn title_style() -> Style {
|
||||
Style::default()
|
||||
.fg(Self::primary_text())
|
||||
.add_modifier(Modifier::BOLD)
|
||||
}
|
||||
|
||||
/// Widget border style (btop default borders)
|
||||
pub fn widget_border_style() -> Style {
|
||||
Style::default().fg(Self::border())
|
||||
}
|
||||
|
||||
/// Inactive widget border style
|
||||
pub fn widget_border_inactive_style() -> Style {
|
||||
Style::default().fg(Self::muted_text())
|
||||
}
|
||||
|
||||
/// Status bar style (btop bottom bar)
|
||||
pub fn status_bar_style() -> Style {
|
||||
Style::default()
|
||||
.fg(Self::secondary_text())
|
||||
.bg(Self::background())
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user