/docs/workstations/telemetry-and-terminal
Workstations webtop-manage v1.0.0

Web Terminal & Live Telemetry

In-browser interactive terminal sessions, real-time SSE metrics, and live stdout/stderr log streaming.

Web Terminal & Live Telemetry

webtop-manage integrates low-overhead, browser-native developer tools directly into the management dashboard.


🖥️ In-Browser WebSocket Web Terminal

Open a direct interactive root shell into any running workstation without configuring SSH keys or running terminal emulators on your local machine:

  1. Click the Terminal icon (>_) on any running instance card.
  2. The interactive modal launches an integrated xterm.js console session connected over secure WebSockets.
code
┌─────────────────────────────────────────────────────────────┐
│ Interactive Terminal — sonic-ubuntu-850               [✕]   │
├─────────────────────────────────────────────────────────────┤
│ [webtop-manage] Connecting to interactive shell...          │
│ [Connected] Interactive session ready.                      │
│                                                             │
│ abc@sonic-ubuntu-850:~$ uname -a                            │
│ Linux sonic-ubuntu-850 6.6.137 #1 SMP PREEMPT x86_64 GNU    │
│ abc@sonic-ubuntu-850:~$ docker --version                    │
│ Docker version 24.0.7, build afdd53b                        │
│ abc@sonic-ubuntu-850:~$ _                                   │
└─────────────────────────────────────────────────────────────┘

Technical Protocol Details

  • Endpoint: GET /api/instances/{id}/terminal (WS upgrade)
  • PTY Execution: Uses Docker Go SDK ContainerExecCreate to spawn /bin/bash with fallback to /bin/sh.
  • Dynamic Window Resizing: The browser window automatically transmits PTY dimensions when resized:
    json
    { "type": "resize", "cols": 120, "rows": 40 }
    
  • Security & CSWSH Protection: The server verifies the Origin header against loopback origins and r.Host, preventing unauthorized cross-site hijacking.

📈 Real-Time Live Telemetry Gauges

Each instance card on the dashboard features live CPU and Memory meters that update continuously over Server-Sent Events:

text
CPU     [█████████░░░░░░░░░░░░░░░░░░░░░]  2.4%
Memory  [████████████████░░░░░░░░░░░░░]  384 MB (19%)

Telemetry Stream Mechanism

  • Endpoint: GET /api/instances/{id}/stats (text/event-stream)
  • Low Daemon Overhead: Reads native Docker container stats streams with < 15MB daemon RAM footprint.
  • Calculated Data Format:
    json
    event: stats
    data: {
      "cpu_percent": 2.4,
      "memory_usage_mb": 384.2,
      "memory_limit_mb": 4096.0,
      "memory_percent": 9.38,
      "network_rx_mb": 1.25,
      "network_tx_mb": 0.84,
      "pids": 32
    }
    

📜 Live Container Logs Console

Stream real-time stdout and stderr logs for troubleshooting application startup and background processes:

  1. Click the Live Logs icon on any instance card.
  2. The log viewer opens an SSE stream (GET /api/instances/{id}/logs?tail=150).

Console Controls

  • Pause / Resume Stream: Freeze the stream to inspect errors without autoscroll interruptions.
  • Real-time Filter: Live search through buffered logs by keyword.
  • Download: Export the full log buffer as a clean .txt file for external debugging.
  • Clear: Wipe the visual console buffer.