|
| 1 | +<!-- |
| 2 | + Licensed to the Apache Software Foundation (ASF) under one |
| 3 | + or more contributor license agreements. See the NOTICE file |
| 4 | + distributed with this work for additional information |
| 5 | + regarding copyright ownership. The ASF licenses this file |
| 6 | + to you under the Apache License, Version 2.0 (the |
| 7 | + "License"); you may not use this file except in compliance |
| 8 | + with the License. You may obtain a copy of the License at |
| 9 | +
|
| 10 | + http://www.apache.org/licenses/LICENSE-2.0 |
| 11 | +
|
| 12 | + Unless required by applicable law or agreed to in writing, software |
| 13 | + distributed under the License is distributed on an "AS IS" BASIS, |
| 14 | + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 15 | + See the License for the specific language governing permissions and |
| 16 | + limitations under the License. |
| 17 | +--> |
| 18 | + |
| 19 | +# Traffic Grapher |
| 20 | + |
| 21 | +Real-time ATS metrics visualization for iTerm2. Displays live graphs of |
| 22 | +requests/sec, latency, cache hit rate, connections, and more — inline in |
| 23 | +your terminal using imgcat. |
| 24 | + |
| 25 | +## Features |
| 26 | + |
| 27 | +- Real-time graphs of RPS, latency, cache hit rate, connections |
| 28 | +- Support for 1–4 hosts with different line styles for comparison |
| 29 | +- Collects metrics via JSONRPC Unix socket (batch collection per host) |
| 30 | +- Dark theme optimized for terminal display |
| 31 | +- Keyboard navigation between 4 metric pages |
| 32 | +- Configurable refresh interval and history window |
| 33 | +- Optional GUI mode via matplotlib window |
| 34 | + |
| 35 | +## Requirements |
| 36 | + |
| 37 | +- Python 3.9+ |
| 38 | +- [uv](https://docs.astral.sh/uv/) (recommended) or pip |
| 39 | +- iTerm2 (or compatible terminal for inline images) |
| 40 | +- SSH access to remote ATS hosts (not needed for localhost) |
| 41 | + |
| 42 | +## Quick Start |
| 43 | + |
| 44 | +```bash |
| 45 | +# Monitor ATS on the local machine (connects directly to JSONRPC socket) |
| 46 | +uv run traffic_grapher.py localhost |
| 47 | + |
| 48 | +# Monitor a remote host (connects via SSH) |
| 49 | +uv run traffic_grapher.py ats-server1.example.com |
| 50 | + |
| 51 | +# Multiple hosts for comparison |
| 52 | +uv run traffic_grapher.py ats-server{1..4}.example.com |
| 53 | + |
| 54 | +# Custom interval and history |
| 55 | +uv run traffic_grapher.py --interval 2 --history 120 ats-server1.example.com |
| 56 | +``` |
| 57 | + |
| 58 | +## Installation (Alternative) |
| 59 | + |
| 60 | +```bash |
| 61 | +# Install as a project |
| 62 | +uv sync |
| 63 | +uv run traffic-grapher ats-server1.example.com |
| 64 | + |
| 65 | +# Or with pip |
| 66 | +pip install . |
| 67 | +traffic-grapher ats-server1.example.com |
| 68 | +``` |
| 69 | + |
| 70 | +## Configuration |
| 71 | + |
| 72 | +### ATS Paths |
| 73 | + |
| 74 | +For localhost, the tool connects directly to the JSONRPC Unix socket. |
| 75 | +For remote hosts, it sends a Python script via SSH that connects to |
| 76 | +the socket on the remote machine. |
| 77 | + |
| 78 | +Configure the socket path via CLI flag or environment variable: |
| 79 | + |
| 80 | +| Option | Env Var | Default | |
| 81 | +|--------|---------|---------| |
| 82 | +| `--socket` | `TRAFFICSERVER_JSONRPC_SOCKET` | `/usr/local/var/trafficserver/jsonrpc20.sock` | |
| 83 | + |
| 84 | +### Custom Dashboards |
| 85 | + |
| 86 | +Create a YAML config file to customize which metrics are displayed: |
| 87 | + |
| 88 | +```bash |
| 89 | +uv run traffic_grapher.py -c my_dashboard.yaml ats-server1.example.com |
| 90 | +``` |
| 91 | + |
| 92 | +## Keyboard Controls |
| 93 | + |
| 94 | +| Key | Action | |
| 95 | +|-----|--------| |
| 96 | +| `h` / `←` | Previous page | |
| 97 | +| `l` / `→` | Next page | |
| 98 | +| `q` | Quit | |
| 99 | + |
| 100 | +## Pages |
| 101 | + |
| 102 | +1. **Traffic & Cache** — Requests/sec, latency, cache hit rate, connections |
| 103 | +2. **Response Codes** — 2xx, 3xx, 4xx, 5xx breakdown |
| 104 | +3. **TLS & HTTP/2** — SSL handshakes, connections, HTTP/2 stats |
| 105 | +4. **Network & Errors** — Bandwidth, connection errors, transaction errors |
| 106 | + |
| 107 | +## Options |
| 108 | + |
| 109 | +``` |
| 110 | +--interval SEC Refresh interval in seconds (default: 1.0) |
| 111 | +--history SEC History window in seconds (default: 60) |
| 112 | +--socket PATH Path to JSONRPC Unix socket on remote host |
| 113 | +--gui Use matplotlib GUI window instead of imgcat |
| 114 | +--once Single snapshot, then exit |
| 115 | +--timezone TZ Timezone for display (default: UTC) |
| 116 | +--save-png FILE Save PNG after each render (use {iter} for iteration) |
| 117 | +--no-keyboard Disable keyboard handling (for non-TTY environments) |
| 118 | +``` |
0 commit comments