Add custom service log file support with L key
All checks were successful
Build and Release / build-and-release (push) Successful in 2m7s
All checks were successful
Build and Release / build-and-release (push) Successful in 2m7s
- Add ServiceLogConfig structure for per-host service log paths - Implement L key handler for custom log file viewing via tmux popup - Update dashboard config to support service_logs HashMap - Add tail -f command execution over SSH for real-time log streaming - Update status line to show L: Custom shortcut - Document configuration format in CLAUDE.md Each service can now have custom log file paths configured per host, accessible via L key with same tmux popup interface as journalctl.
This commit is contained in:
parent
1b64fbde3d
commit
3f6dffa66e
17
CLAUDE.md
17
CLAUDE.md
@ -20,12 +20,28 @@ A high-performance Rust-based TUI dashboard for monitoring CMTEC infrastructure.
|
|||||||
- Persistent storage survives agent restarts
|
- Persistent storage survives agent restarts
|
||||||
- Automatic flag clearing when services are restarted via dashboard
|
- 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
|
### Service Management
|
||||||
- **Direct Control**: Arrow keys (↑↓) or vim keys (j/k) navigate services
|
- **Direct Control**: Arrow keys (↑↓) or vim keys (j/k) navigate services
|
||||||
- **Service Actions**:
|
- **Service Actions**:
|
||||||
- `s` - Start service (sends UserStart command)
|
- `s` - Start service (sends UserStart command)
|
||||||
- `S` - Stop service (sends UserStop command)
|
- `S` - Stop service (sends UserStop command)
|
||||||
- `J` - Show service logs (journalctl in tmux popup)
|
- `J` - Show service logs (journalctl in tmux popup)
|
||||||
|
- `L` - Show custom log files (tail -f custom paths in tmux popup)
|
||||||
- `R` - Rebuild current host
|
- `R` - Rebuild current host
|
||||||
- **Visual Status**: Green ● (active), Yellow ◐ (inactive), Red ◯ (failed)
|
- **Visual Status**: Green ● (active), Yellow ◐ (inactive), Red ◯ (failed)
|
||||||
- **Transitional Icons**: Blue arrows during operations
|
- **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
|
- **Tab**: Switch between hosts
|
||||||
- **↑↓ or j/k**: Select services
|
- **↑↓ or j/k**: Select services
|
||||||
- **J**: Show service logs (journalctl)
|
- **J**: Show service logs (journalctl)
|
||||||
|
- **L**: Show custom log files
|
||||||
- **q**: Quit dashboard
|
- **q**: Quit dashboard
|
||||||
|
|
||||||
## Core Architecture Principles
|
## Core Architecture Principles
|
||||||
|
|||||||
6
Cargo.lock
generated
6
Cargo.lock
generated
@ -270,7 +270,7 @@ checksum = "a1d728cc89cf3aee9ff92b05e62b19ee65a02b5702cff7d5a377e32c6ae29d8d"
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "cm-dashboard"
|
name = "cm-dashboard"
|
||||||
version = "0.1.48"
|
version = "0.1.49"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"anyhow",
|
"anyhow",
|
||||||
"chrono",
|
"chrono",
|
||||||
@ -291,7 +291,7 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "cm-dashboard-agent"
|
name = "cm-dashboard-agent"
|
||||||
version = "0.1.48"
|
version = "0.1.49"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"anyhow",
|
"anyhow",
|
||||||
"async-trait",
|
"async-trait",
|
||||||
@ -314,7 +314,7 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "cm-dashboard-shared"
|
name = "cm-dashboard-shared"
|
||||||
version = "0.1.48"
|
version = "0.1.49"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"chrono",
|
"chrono",
|
||||||
"serde",
|
"serde",
|
||||||
|
|||||||
@ -1,6 +1,6 @@
|
|||||||
[package]
|
[package]
|
||||||
name = "cm-dashboard-agent"
|
name = "cm-dashboard-agent"
|
||||||
version = "0.1.49"
|
version = "0.1.50"
|
||||||
edition = "2021"
|
edition = "2021"
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
|
|||||||
@ -1,6 +1,6 @@
|
|||||||
[package]
|
[package]
|
||||||
name = "cm-dashboard"
|
name = "cm-dashboard"
|
||||||
version = "0.1.49"
|
version = "0.1.50"
|
||||||
edition = "2021"
|
edition = "2021"
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
|
|||||||
@ -9,6 +9,7 @@ pub struct DashboardConfig {
|
|||||||
pub hosts: HostsConfig,
|
pub hosts: HostsConfig,
|
||||||
pub system: SystemConfig,
|
pub system: SystemConfig,
|
||||||
pub ssh: SshConfig,
|
pub ssh: SshConfig,
|
||||||
|
pub service_logs: std::collections::HashMap<String, Vec<ServiceLogConfig>>,
|
||||||
}
|
}
|
||||||
|
|
||||||
/// ZMQ consumer configuration
|
/// ZMQ consumer configuration
|
||||||
@ -39,6 +40,13 @@ pub struct SshConfig {
|
|||||||
pub rebuild_alias: String,
|
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 {
|
impl DashboardConfig {
|
||||||
pub fn load_from_file<P: AsRef<Path>>(path: P) -> Result<Self> {
|
pub fn load_from_file<P: AsRef<Path>>(path: P) -> Result<Self> {
|
||||||
let path = path.as_ref();
|
let path = path.as_ref();
|
||||||
|
|||||||
@ -308,6 +308,34 @@ ssh -tt {}@{} 'bash -ic {}'",
|
|||||||
.ok(); // Ignore errors, tmux will handle them
|
.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') => {
|
KeyCode::Char('b') => {
|
||||||
// Trigger backup
|
// Trigger backup
|
||||||
if let Some(hostname) = self.current_host.clone() {
|
if let Some(hostname) = self.current_host.clone() {
|
||||||
@ -718,6 +746,7 @@ ssh -tt {}@{} 'bash -ic {}'",
|
|||||||
shortcuts.push("r: Rebuild".to_string());
|
shortcuts.push("r: Rebuild".to_string());
|
||||||
shortcuts.push("s/S: Start/Stop".to_string());
|
shortcuts.push("s/S: Start/Stop".to_string());
|
||||||
shortcuts.push("J: Logs".to_string());
|
shortcuts.push("J: Logs".to_string());
|
||||||
|
shortcuts.push("L: Custom".to_string());
|
||||||
|
|
||||||
// Always show quit
|
// Always show quit
|
||||||
shortcuts.push("q: Quit".to_string());
|
shortcuts.push("q: Quit".to_string());
|
||||||
|
|||||||
@ -1,6 +1,6 @@
|
|||||||
[package]
|
[package]
|
||||||
name = "cm-dashboard-shared"
|
name = "cm-dashboard-shared"
|
||||||
version = "0.1.49"
|
version = "0.1.50"
|
||||||
edition = "2021"
|
edition = "2021"
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user