cm-dashboard/README.md

136 lines
5.6 KiB
Markdown

# CM Dashboard
CM Dashboard is a Rust-powered terminal UI for real-time monitoring of CMTEC infrastructure hosts. It subscribes to the CMTEC ZMQ gossip network where lightweight agents publish SMART, service, and backup metrics, and presents them in an efficient, keyboard-driven interface built with `ratatui`.
```
┌──────────────────────────────────────────────────────────────────────────────┐
│ CM Dashboard │
├────────────────────────────┬────────────────────────────┬────────────────────┤
│ NVMe Health │ Services │ Memory Optimization │
│ Host: srv01 │ Host: srv01 │ Host: srv01 │
│ Status: Healthy │ Services healthy: 5 │ Memory used: 2048 / │
│ Drives healthy/warn/crit: │ Degraded: 1 Failed: 0 │ 4096 MiB (50.0%) │
│ 4/0/0 │ CPU top service: 71.3% │ Last update: 12:34: │
│ Capacity used: 512.0 / │ Total memory: 1536 / 2048 │ 56 │
│ 2048.0 GiB │ MiB │ │
├────────────────────────────┴────────────┬───────────────┴────────────────────┤
│ Backups │ Alerts │
│ Host: srv01 │ srv01: OK │
│ Status: Healthy │ labbox: smart warning │
│ Last success: 2024-02-01 03:12:45 │ │
│ Snapshots: 17 • Size: 512.0 GiB │ │
│ Pending jobs: 0 (enabled: true) │ │
└──────────────────────────────┬───────────────────────────────────────────────┘
│ Status │ │
│ Active host: srv01 (1/3) │ History retention ≈ 3600s │
│ Config: config/dashboard.toml│ Default host: labbox │
└──────────────────────────────┴───────────────────────────────────────────────┘
```
## Requirements
- Rust toolchain 1.75+ (install via [`rustup`](https://rustup.rs))
- Network access to the CMTEC metrics gossip agents (default `tcp://<host>:6130`)
- Configuration files under `config/` describing hosts and dashboard preferences
## Installation
Clone the repository and build with Cargo:
```bash
git clone https://github.com/cmtec/cm-dashboard.git
cd cm-dashboard
cargo build --release
```
The optimized binary is available at `target/release/cm-dashboard`. To install into your Cargo bin directory:
```bash
cargo install --path .
```
## Configuration
On first launch, the dashboard will create `config/dashboard.toml` and `config/hosts.toml` automatically if they do not exist.
You can also generate starter configuration files manually with the built-in helper:
```bash
cargo run -- init-config
# or, once installed
cm-dashboard init-config --dir ./config --force
```
This produces `config/dashboard.toml` and `config/hosts.toml`. The primary dashboard config looks like:
```toml
[hosts]
default_host = "srv01"
[[hosts.hosts]]
name = "srv01"
enabled = true
[[hosts.hosts]]
name = "labbox"
enabled = true
[dashboard]
tick_rate_ms = 250
history_duration_minutes = 60
[[dashboard.widgets]]
id = "nvme"
enabled = true
[[dashboard.widgets]]
id = "alerts"
enabled = true
[data_source]
kind = "zmq"
[data_source.zmq]
endpoints = ["tcp://127.0.0.1:6130"]
```
Adjust the host list and `data_source.zmq.endpoints` to match your CMTEC gossip network. If you prefer to manage hosts separately, edit the generated `hosts.toml` file.
## Features
- Rotating host selection with left/right arrows (`←`, `→`, `h`, `l`, `Tab`)
- Live NVMe, service, memory, backup, and alert summaries per active host
- Structured logging with `tracing` (`-v`/`-vv` to increase verbosity)
- Help overlay (`?`) outlining keyboard shortcuts
- Config-driven host discovery via `config/dashboard.toml`
## Getting Started
```bash
cargo run -- --config config/dashboard.toml
# specify a single host
cargo run -- --host srv01
# override ZMQ endpoints at runtime
cargo run -- --zmq-endpoint tcp://srv01:6130,tcp://labbox:6130
# increase logging verbosity
cargo run -- -v
```
### Keyboard Shortcuts
| Key | Action |
| --- | --- |
| `←` / `h` | Previous host |
| `→` / `l` / `Tab` | Next host |
| `?` | Toggle help overlay |
| `r` | Update status message |
| `q` / `Esc` | Quit |
## Development
- Format: `cargo fmt`
- Check: `cargo check`
- Run: `cargo run`
The dashboard subscribes to the CMTEC ZMQ gossip network (default `tcp://127.0.0.1:6130`). Received metrics are cached per host and retained in an in-memory ring buffer for future trend analysis.