diff --git a/CLAUDE.md b/CLAUDE.md index cfc3964..45ea8ac 100644 --- a/CLAUDE.md +++ b/CLAUDE.md @@ -20,12 +20,28 @@ A high-performance Rust-based TUI dashboard for monitoring CMTEC infrastructure. - Persistent storage survives agent restarts - Automatic flag clearing when services are restarted via dashboard +### Custom Service Logs +- Configure service-specific log file paths per host in dashboard config +- Press `L` on any service to view custom log files via `tail -f` +- Configuration format in dashboard config: +```toml +[service_logs] +hostname1 = [ + { service_name = "nginx", log_file_path = "/var/log/nginx/access.log" }, + { service_name = "app", log_file_path = "/var/log/myapp/app.log" } +] +hostname2 = [ + { service_name = "database", log_file_path = "/var/log/postgres/postgres.log" } +] +``` + ### Service Management - **Direct Control**: Arrow keys (↑↓) or vim keys (j/k) navigate services - **Service Actions**: - `s` - Start service (sends UserStart command) - `S` - Stop service (sends UserStop command) - `J` - Show service logs (journalctl in tmux popup) + - `L` - Show custom log files (tail -f custom paths in tmux popup) - `R` - Rebuild current host - **Visual Status**: Green ● (active), Yellow ◐ (inactive), Red ◯ (failed) - **Transitional Icons**: Blue arrows during operations @@ -34,6 +50,7 @@ A high-performance Rust-based TUI dashboard for monitoring CMTEC infrastructure. - **Tab**: Switch between hosts - **↑↓ or j/k**: Select services - **J**: Show service logs (journalctl) +- **L**: Show custom log files - **q**: Quit dashboard ## Core Architecture Principles diff --git a/Cargo.lock b/Cargo.lock index 36a4249..0300590 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -270,7 +270,7 @@ checksum = "a1d728cc89cf3aee9ff92b05e62b19ee65a02b5702cff7d5a377e32c6ae29d8d" [[package]] name = "cm-dashboard" -version = "0.1.48" +version = "0.1.49" dependencies = [ "anyhow", "chrono", @@ -291,7 +291,7 @@ dependencies = [ [[package]] name = "cm-dashboard-agent" -version = "0.1.48" +version = "0.1.49" dependencies = [ "anyhow", "async-trait", @@ -314,7 +314,7 @@ dependencies = [ [[package]] name = "cm-dashboard-shared" -version = "0.1.48" +version = "0.1.49" dependencies = [ "chrono", "serde", diff --git a/agent/Cargo.toml b/agent/Cargo.toml index 08f399b..048a496 100644 --- a/agent/Cargo.toml +++ b/agent/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "cm-dashboard-agent" -version = "0.1.49" +version = "0.1.50" edition = "2021" [dependencies] diff --git a/dashboard/Cargo.toml b/dashboard/Cargo.toml index 27f9bce..f574ac7 100644 --- a/dashboard/Cargo.toml +++ b/dashboard/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "cm-dashboard" -version = "0.1.49" +version = "0.1.50" edition = "2021" [dependencies] diff --git a/dashboard/src/config/mod.rs b/dashboard/src/config/mod.rs index 2f272bb..ab2975b 100644 --- a/dashboard/src/config/mod.rs +++ b/dashboard/src/config/mod.rs @@ -9,6 +9,7 @@ pub struct DashboardConfig { pub hosts: HostsConfig, pub system: SystemConfig, pub ssh: SshConfig, + pub service_logs: std::collections::HashMap>, } /// ZMQ consumer configuration @@ -39,6 +40,13 @@ pub struct SshConfig { pub rebuild_alias: String, } +/// Service log file configuration per host +#[derive(Debug, Clone, Serialize, Deserialize)] +pub struct ServiceLogConfig { + pub service_name: String, + pub log_file_path: String, +} + impl DashboardConfig { pub fn load_from_file>(path: P) -> Result { let path = path.as_ref(); diff --git a/dashboard/src/ui/mod.rs b/dashboard/src/ui/mod.rs index 5a5772f..469aa78 100644 --- a/dashboard/src/ui/mod.rs +++ b/dashboard/src/ui/mod.rs @@ -308,6 +308,34 @@ ssh -tt {}@{} 'bash -ic {}'", .ok(); // Ignore errors, tmux will handle them } } + KeyCode::Char('L') => { + // Show custom service log file in tmux popup + if let (Some(service_name), Some(hostname)) = (self.get_selected_service(), self.current_host.clone()) { + // Check if this service has a custom log file configured + if let Some(host_logs) = self.config.service_logs.get(&hostname) { + if let Some(log_config) = host_logs.iter().find(|config| config.service_name == service_name) { + let tail_command = format!( + "ssh -tt {}@{} 'tail -f {}'", + self.config.ssh.rebuild_user, + hostname, + log_config.log_file_path + ); + + std::process::Command::new("tmux") + .arg("display-popup") + .arg("-w") + .arg("80%") + .arg("-h") + .arg("80%") + .arg("-T") + .arg(format!("Custom Log: {}", service_name)) + .arg(&tail_command) + .spawn() + .ok(); // Ignore errors, tmux will handle them + } + } + } + } KeyCode::Char('b') => { // Trigger backup if let Some(hostname) = self.current_host.clone() { @@ -718,6 +746,7 @@ ssh -tt {}@{} 'bash -ic {}'", shortcuts.push("r: Rebuild".to_string()); shortcuts.push("s/S: Start/Stop".to_string()); shortcuts.push("J: Logs".to_string()); + shortcuts.push("L: Custom".to_string()); // Always show quit shortcuts.push("q: Quit".to_string()); diff --git a/shared/Cargo.toml b/shared/Cargo.toml index 0f87b6d..45eefeb 100644 --- a/shared/Cargo.toml +++ b/shared/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "cm-dashboard-shared" -version = "0.1.49" +version = "0.1.50" edition = "2021" [dependencies]