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:
2025-10-16 23:55:05 +02:00
parent 7a664ef0fb
commit 8a36472a3d
81 changed files with 7702 additions and 9608 deletions

View File

@@ -2,52 +2,21 @@ use thiserror::Error;
#[derive(Debug, Error)]
pub enum CollectorError {
#[error("Command execution failed: {command} - {message}")]
CommandFailed { command: String, message: String },
#[error("Permission denied: {message}")]
PermissionDenied { message: String },
#[error("Data parsing error: {message}")]
ParseError { message: String },
#[error("Timeout after {duration_ms}ms")]
Timeout { duration_ms: u64 },
#[error("IO error: {message}")]
IoError { message: String },
#[error("Failed to read system file {path}: {error}")]
SystemRead { path: String, error: String },
#[error("Failed to parse value '{value}': {error}")]
Parse { value: String, error: String },
#[error("System command failed: {command}: {error}")]
CommandFailed { command: String, error: String },
#[error("Configuration error: {message}")]
ConfigError { message: String },
#[error("Service not found: {service}")]
ServiceNotFound { service: String },
#[error("Device not found: {device}")]
DeviceNotFound { device: String },
#[error("External dependency error: {dependency} - {message}")]
ExternalDependency { dependency: String, message: String },
}
impl From<std::io::Error> for CollectorError {
fn from(err: std::io::Error) -> Self {
CollectorError::IoError {
message: err.to_string(),
}
}
}
impl From<serde_json::Error> for CollectorError {
fn from(err: serde_json::Error) -> Self {
CollectorError::ParseError {
message: err.to_string(),
}
}
}
impl From<tokio::time::error::Elapsed> for CollectorError {
fn from(_: tokio::time::error::Elapsed) -> Self {
CollectorError::Timeout { duration_ms: 0 }
}
}
Configuration { message: String },
#[error("Metric calculation error: {message}")]
Calculation { message: String },
#[error("Timeout error: operation took longer than {timeout_ms}ms")]
Timeout { timeout_ms: u64 },
}