# 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 • cmbox │ ├─────────────────────────────────────────────────────────────────────┤ │ Storage • ok:1 warn:0 crit:0 │ Services • ok:1 warn:0 fail:0 │ │ ┌─────────────────────────────────┐ │ ┌─────────────────────────────── │ │ │ │Drive Temp Wear Spare Hours │ │ │Service memory: 7.1/23899.7 MiB│ │ │ │nvme0n1 28°C 1% 100% 14489 │ │ │Disk usage: — │ │ │ │ Capacity Usage │ │ │ Service Memory Disk │ │ │ │ 954G 77G (8%) │ │ │✔ sshd 7.1 MiB — │ │ │ └─────────────────────────────────┘ │ └─────────────────────────────── │ │ ├─────────────────────────────────────────────────────────────────────┤ │ CPU / Memory • warn │ Backups │ │ System memory: 5251.7/23899.7 MiB │ Host cmbox awaiting backup │ │ │ CPU load (1/5/15): 2.18 2.66 2.56 │ metrics │ │ │ CPU freq: 1100.1 MHz │ │ │ │ CPU temp: 47.0°C │ │ │ ├─────────────────────────────────────────────────────────────────────┤ │ Alerts • ok:0 warn:3 fail:0 │ Status • ZMQ connected │ │ cmbox: warning: CPU load 2.18 │ Monitoring • hosts: 3 │ │ │ srv01: pending: awaiting metrics │ Data source: ZMQ – connected │ │ │ labbox: pending: awaiting metrics │ Active host: cmbox (1/3) │ │ └─────────────────────────────────────────────────────────────────────┘ Keys: [←→] hosts [r]efresh [q]uit ``` ## Requirements - Rust toolchain 1.75+ (install via [`rustup`](https://rustup.rs)) - Network access to the CMTEC metrics gossip agents (default `tcp://:6130`; install `zeromq`/`libzmq` on the host) - 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 dashboard ``` ## 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 -p cm-dashboard -- 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 - **Real-time monitoring** with ZMQ gossip network architecture - **Storage health** with drive capacity, usage, temperature, and wear tracking - **Per-service resource tracking** including memory and disk usage by service - **CPU/Memory monitoring** with load averages, temperature, and GPU metrics - **Alert system** with color-coded highlighting and threshold-based warnings - **Multi-host support** with seamless host switching (`←`, `→`, `h`, `l`, `Tab`) - **Backup status** monitoring with restic integration - **Keyboard-driven interface** with help overlay (`?`) - **Configuration management** via TOML files for hosts and dashboard settings ## Getting Started ```bash cargo run -p cm-dashboard -- --config config/dashboard.toml # specify a single host cargo run -p cm-dashboard -- --host srv01 # override ZMQ endpoints at runtime cargo run -p cm-dashboard -- --zmq-endpoint tcp://srv01:6130,tcp://labbox:6130 # increase logging verbosity cargo run -p cm-dashboard -- -v ``` ### Keyboard Shortcuts | Key | Action | | --- | --- | | `←` / `h` | Previous host | | `→` / `l` / `Tab` | Next host | | `?` | Toggle help overlay | | `r` | Update status message | | `q` / `Esc` | Quit | ## Agent The metrics agent runs on each host and publishes SMART, service, and backup data to the ZMQ gossip network. The agent auto-detects system configuration and requires root privileges for hardware monitoring. ```bash # Run agent with auto-detection sudo cargo run -p cm-dashboard-agent # Run with specific configuration sudo cargo run -p cm-dashboard-agent -- --config config/agent.toml # Manual configuration sudo cargo run -p cm-dashboard-agent -- \ --hostname srv01 \ --bind tcp://*:6130 \ --smart-devices nvme0n1,sda \ --services nginx,postgres ``` The agent automatically: - Detects available storage devices for SMART monitoring - Discovers running systemd services for resource tracking - Configures appropriate collection intervals per host type - Requires root access for `smartctl` and system metrics Use `--disable-smart`, `--disable-service`, or `--disable-backup` to skip specific collectors. ## Development - Format: `cargo fmt` - Check workspace: `cargo check` - Build release binaries: `cargo build --release` 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.