README
¶
cake-stats
Real-time web UI for monitoring CAKE SQM (Smart Queue Management) statistics on Linux/OpenWrt routers.
Table of Contents
- How it looks like
- Status
- Features
- Requirements
- Build
- Usage
- Design Notes
- Limitations & Next Steps
- Contributing
- License
How it looks like
Desktop
UI for desktop screens
Graphs for desktop screens
Mobile
UI for mobile screens
Graphs for mobile screens
Status
- Stable — all parser unit tests passing, binary builds clean for 14 target platforms.
Features
- Automatically discovers all CAKE qdiscs via
tc -s qdisc - Parses every CAKE field: thresh, target, interval, pk_delay, av_delay, sp_delay, backlog, pkts, bytes, way_inds, way_miss, way_cols, drops, marks, ack_drop, sp_flows, bk_flows, un_flows, max_len, quantum
- Correctly handles diffserv modes:
diffserv3,diffserv4,diffserv8,besteffort,precedence; also parses the separatefwmark MASKtin-override parameter - Two-word tier names are joined correctly (e.g.
"Best Effort") - Real-time push via Server-Sent Events — no WebSocket, no polling jitter
- Single static binary — no runtime dependencies; runs on OpenWrt with ≈4 MB of RAM overhead
- Web UI: dark TUI aesthetic (
#2D3C59bg, JetBrains Mono, zero hover animations) - Responsive for desktop and mobile (sticky first column, horizontal scroll on small screens)
- Per-interface live sparklines (TX throughput, avg latency, drops/s) with current-value labels
- Tap/click any sparkline bar to open a full-screen history modal with three uPlot time-series charts
- Server-side ring buffer retains history across page reloads (configurable via
-historyflag)
Requirements
- Linux kernel with
tc+sch_cakemodule loaded, or OpenWrt withkmod-sched-cake - Go 1.22+ (build only; not needed at runtime)
Build
git clone https://github.com/galpt/cake-stats
cd cake-stats
go test ./... # should print PASS
go build -o cake-stats .
Cross-compile for a MIPS OpenWrt router:
CGO_ENABLED=0 GOOS=linux GOARCH=mips GOMIPS=softfloat \
go build -ldflags "-s -w" -o cake-stats-linux-mips .
Pre-built binaries for all common platforms are attached to every GitHub Release.
Usage
Quick start
./cake-stats # serves on http://0.0.0.0:11112
./cake-stats -port 8080 # custom port
./cake-stats -interval 2s # poll tc every 2 seconds (default 1s)
./cake-stats -history 3600 # retain 1 hour of history (default 300 = 5 min)
./cake-stats -host 127.0.0.1 # listen only on loopback
./cake-stats -version # print version and exit
Open http://<router-ip>:11112 in a browser.
Install on OpenWrt
sh install.sh # auto-detects arch, downloads latest binary
sh install.sh --port 11112 --interval 1s
Install on systemd Linux
sudo sh install.sh
Uninstall
sh uninstall.sh # prompts for confirmation
sh uninstall.sh --force # no prompts
API
| Endpoint | Description |
|---|---|
GET / |
Web UI (HTML) |
GET /api/stats |
Current stats snapshot (JSON) |
GET /api/history |
Full ring-buffer history per interface (JSON), used to seed sparklines on page load |
GET /events |
SSE stream — emits updated JSON on every poll interval |
Design Notes
- Pure stdlib Go: no external dependencies; the binary embeds
index.htmlvia//go:embed. - SSE over WebSocket: server-to-client only push makes SSE sufficient and simpler; browsers handle automatic reconnection.
uint64for all counters: avoids overflow for high-throughput links; max ~18.4 EB.sync.RWMutex: a single reader/writer lock separates the poller goroutine from concurrent HTTP handlers.- Delay fields as strings:
pk_delay,av_delay,sp_delayare kept as raw strings (e.g.,"6.73ms") so the unit suffix is preserved. - Ring-buffer history:
HistoryStoreallocates a fixed-size ring per interface at startup; memory is bounded bycapacity × interfaces × ~40 Band never grows. Configurable via-history N(default 300 samples ≈ 5 min at 1 s interval). - Sparklines: pure SVG polylines drawn in-place inside stable DOM nodes so the per-second innerHTML swap of the stats table does not affect them. uPlot (CDN) is used only for the full-screen history modal.
Limitations & Next Steps
- No authentication; if exposing to the internet, put behind a reverse proxy with basic auth.
- Windows/FreeBSD builds are provided but CAKE is a Linux-only qdisc.
Contributing
go test ./... # run unit tests
go vet ./... # static analysis
PRs welcome. Please keep external dependencies at zero.
License
Documentation
¶
There is no documentation for this package.
Click to show internal directories.
Click to hide internal directories.