Compare commits
3 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| e4469a0ebf | |||
| 6fedf4c7fc | |||
| 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.51"
|
||||||
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.51"
|
||||||
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.51"
|
||||||
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.52"
|
||||||
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.52"
|
||||||
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();
|
||||||
|
|||||||
@@ -244,14 +244,20 @@ impl TuiApp {
|
|||||||
KeyCode::Char('r') => {
|
KeyCode::Char('r') => {
|
||||||
// System rebuild command - works on any panel for current host
|
// System rebuild command - works on any panel for current host
|
||||||
if let Some(hostname) = self.current_host.clone() {
|
if let Some(hostname) = self.current_host.clone() {
|
||||||
// Create command that shows CM Dashboard logo and then rebuilds
|
// Create command that shows logo, rebuilds, and waits for user input
|
||||||
let logo_and_rebuild = format!(
|
let logo_and_rebuild = format!(
|
||||||
r"cat << 'EOF'
|
r"bash -c 'cat << \"EOF\"
|
||||||
NixOS System Rebuild
|
NixOS System Rebuild
|
||||||
Target: {}
|
Target: {}
|
||||||
|
|
||||||
EOF
|
EOF
|
||||||
ssh -tt {}@{} 'bash -ic {}'",
|
ssh -tt {}@{} \"bash -ic {}\"
|
||||||
|
echo
|
||||||
|
echo \"========================================\"
|
||||||
|
echo \"Rebuild completed. Press any key to close...\"
|
||||||
|
echo \"========================================\"
|
||||||
|
read -n 1 -s
|
||||||
|
exit'",
|
||||||
hostname,
|
hostname,
|
||||||
self.config.ssh.rebuild_user,
|
self.config.ssh.rebuild_user,
|
||||||
hostname,
|
hostname,
|
||||||
@@ -259,11 +265,10 @@ ssh -tt {}@{} 'bash -ic {}'",
|
|||||||
);
|
);
|
||||||
|
|
||||||
std::process::Command::new("tmux")
|
std::process::Command::new("tmux")
|
||||||
.arg("display-popup")
|
.arg("split-window")
|
||||||
.arg("-w")
|
.arg("-v")
|
||||||
.arg("80%")
|
.arg("-p")
|
||||||
.arg("-h")
|
.arg("30")
|
||||||
.arg("80%")
|
|
||||||
.arg(&logo_and_rebuild)
|
.arg(&logo_and_rebuild)
|
||||||
.spawn()
|
.spawn()
|
||||||
.ok(); // Ignore errors, tmux will handle them
|
.ok(); // Ignore errors, tmux will handle them
|
||||||
@@ -286,28 +291,50 @@ ssh -tt {}@{} 'bash -ic {}'",
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
KeyCode::Char('J') => {
|
KeyCode::Char('J') => {
|
||||||
// Show service logs via journalctl in tmux popup
|
// Show service logs via journalctl in tmux split window
|
||||||
if let (Some(service_name), Some(hostname)) = (self.get_selected_service(), self.current_host.clone()) {
|
if let (Some(service_name), Some(hostname)) = (self.get_selected_service(), self.current_host.clone()) {
|
||||||
let journalctl_command = format!(
|
let journalctl_command = format!(
|
||||||
"ssh -tt {}@{} 'journalctl -u {}.service -f --no-pager -n 50'",
|
"bash -c \"ssh -tt {}@{} 'sudo journalctl -u {}.service -f --no-pager -n 50'; exit\"",
|
||||||
self.config.ssh.rebuild_user,
|
self.config.ssh.rebuild_user,
|
||||||
hostname,
|
hostname,
|
||||||
service_name
|
service_name
|
||||||
);
|
);
|
||||||
|
|
||||||
std::process::Command::new("tmux")
|
std::process::Command::new("tmux")
|
||||||
.arg("display-popup")
|
.arg("split-window")
|
||||||
.arg("-w")
|
.arg("-v")
|
||||||
.arg("80%")
|
.arg("-p")
|
||||||
.arg("-h")
|
.arg("30")
|
||||||
.arg("80%")
|
|
||||||
.arg("-T")
|
|
||||||
.arg(format!("Logs: {}", service_name))
|
|
||||||
.arg(&journalctl_command)
|
.arg(&journalctl_command)
|
||||||
.spawn()
|
.spawn()
|
||||||
.ok(); // Ignore errors, tmux will handle them
|
.ok(); // Ignore errors, tmux will handle them
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
KeyCode::Char('L') => {
|
||||||
|
// Show custom service log file in tmux split window
|
||||||
|
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!(
|
||||||
|
"bash -c \"ssh -tt {}@{} 'sudo tail -n 50 -f {}'; exit\"",
|
||||||
|
self.config.ssh.rebuild_user,
|
||||||
|
hostname,
|
||||||
|
log_config.log_file_path
|
||||||
|
);
|
||||||
|
|
||||||
|
std::process::Command::new("tmux")
|
||||||
|
.arg("split-window")
|
||||||
|
.arg("-v")
|
||||||
|
.arg("-p")
|
||||||
|
.arg("30")
|
||||||
|
.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 +745,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.52"
|
||||||
edition = "2021"
|
edition = "2021"
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
|
|||||||
Reference in New Issue
Block a user