Cgmon — uplink, port and device monitor for OpenWrt that only loads kernel rules (Rust, ~1 MB, all archs)

Hi all,

I'd like to share a project I've been running on my own routers for a while: cgmon, a monitor for the internet uplink, devices, switch ports and traffic on OpenWrt / ImmortalWrt. It is GPL-3.0, and I'm the author.

The design idea: cgmon is a conductor, not a router. No packet ever passes through it — the kernel forwards everything as usual. cgmon watches through the kernel (conntrack and nftables counters over netlink, AF_PACKET copies of SYN/RST and DNS answers, sysfs/ethtool for ports) and, only when you enable it, loads its own rules: separate nftables tables next to fw4 (fw4 rules are never edited, the firewall is never reloaded), ip rule/routing tables, a tc queue. If cgmon stops or crashes, the router keeps working with the last rules.

What it does:

  • WAN state from TCP probes over IPv4 and IPv6, with a plain-language incident journal (e.g. "IPv4 failing while IPv6 works — provider-side CGNAT issue")
  • down detector: which sites stop answering your clients while the internet is fine, and a TCP-traceroute "culprit search" that names the peering point all bad paths share
  • ports and cables: link drops, CRC errors, downshifts — also per port of swconfig switches
  • per-device traffic with a chart whose history is kept on the router
  • gateway failover and per-network gateway maps (works with the stock busybox ip)
  • optional SQM (cake/HTB), an upload shaper, a DNS guard for one-protocol failures
  • a hub that collects state from several routers and alerts in Telegram (encrypted reports)

It is a single static binary with the web page embedded: ~1 MB UPX-packed (lite/nano builds) or 2–3 MB plain, 3–5 MB RAM. It runs on a TL-WR1043ND as well as on x86. Builds for x86_64, i686, aarch64, armv7, armv5te, mips and mipsel, plus .apk (25.x) and .ipk (24.10 and older) packages that check the CPU before installing. Out of the box it only observes — nothing is blocked, shaped or sent anywhere until you turn it on.

Honest limitations: journal messages and the CLI are still in Russian (the web UI is in English); the packages are not signed (apk add --allow-untrusted); conntrack-heavy features cost some CPU on very weak routers.

Code, screenshots and releases: https://github.com/real4root/cgmon

I'd be glad to hear feedback, especially from people on hardware I haven't tested (ramips mt7621, ipq40xx, mvebu).

4 Likes

Looks great, thanks, where is the OpenWrt package Makefile?, I want to build from source by myself.

Thanks! The OpenWrt package Makefile is now in the repo: https://github.com/real4root/cgmon/tree/main/openwrt/package/cgmon

It follows the packages feed layout and uses lang/rust/rust-package.mk, with three variants: cgmon (full), cgmon-lite (no SmartDNS-based features) and cgmon-nano (stock image only). To build it in a buildroot or SDK that has the packages feed:

cp -r openwrt/package/cgmon feeds/packages/net/cgmon
./scripts/feeds update -i packages && ./scripts/feeds install cgmon
make menuconfig     # Network -> Network monitoring -> cgmon / cgmon-lite / cgmon-nano
make package/cgmon/compile V=s

The package installs /usr/sbin/cgmon, a procd service and a minimal /etc/cgmon/cgmon.yaml (a conffile). It builds with the standard OpenWrt Rust profile (overflow checks, unwind, --locked); the .cargo/config.toml in the tree only holds my own cross-linkers and is removed in Build/Prepare.

I'm preparing it for a pull request to openwrt/packages, so any feedback from a real SDK build — especially on mips/mipsel — is very welcome.

1 Like

Great, compiling and testing for x86_64 and aarch64

luci-app-cgmon is still in russian.

cgmon 2.4.22 → 2.6.31 — changelog

:rocket: New features

  • Per-Site Routing — on-the-fly bypass of name-based blocking: cgmon detects, from real client traffic, sites the ISP tears down by TLS name (SNI) — or silently drops the ClientHello with no RST (caught by repeated handshakes, 2.6.28) — confirms with a direct probe, and routes them through a chosen gateway (VPN/relay) for 24 h; the owner's IPv6 /48 is refused so clients fall straight to IPv4.
  • Overlay "all-traffic" gateway (2.6.8) — a tunnel picked in the gateway builder carries all LAN internet through itself via an overlay mark, without changing the main route; the physical link is an automatic fallback.
  • Relay nodes as gateways — your own routers in ZeroTier/LAN as reroute paths, no exit node required.
  • Friendly gateway names — devices are classified (ZeroTier/Tailscale/WireGuard/…) and shown by human names, shared across Per-Site Routing, targeted reroute and the gate selector.
  • Gateway maps — a LAN group/device → an ordered list of gateways.
  • On-router chart history (1 h + 24 h), top devices per point, row highlight on hover.
  • Page embedded in the binary — deploying the page = deploying cgmon.
  • Choice of where data is stored (flash / tmp / custom directory).
  • English LuCI app (luci-app-cgmon) — 2.6.30.
  • lite/nano builds + one-click package install, 7 architectures (incl. MIPS/MIPSel), .apk and .ipk packages.

:artist_palette: Interface ("2026" UI)

  • Settings as cards with switches and a sticky "Apply" bar.
  • Settings search ("find a setting").
  • A "Current events" block above the chart — only what matters right now.
  • Incidents / down detector / hub journal — one line per record with a details popup; per-network routing shown as cards.
  • A blue circled "?" next to every setting with a hint (from the cgmon.yaml comments), without increasing row height.

:compass: Settings order & logic

  • Per-Site VPN → Per-Site Routing; the "my IP" check sites moved into this card.
  • "L2 gateways" → "Extra gateways in networks" + an add/remove widget for relay nodes with auto-detected parent interface.
  • A "Gateway maps" header with a "+ map" button.
  • Broken-route timings grouped and reordered.
  • "Upload learner" → "Smart upload monitor".
  • A relay path is shown as node1 (zt0), consistent with the other paths (2.6.31).

:lady_beetle: Fixes

  • The "+ map" button opened the tooltip instead of adding a map (2.6.27).
1 Like

I fix it in cgmon 2.6.30

1 Like

There are still russian only language in various places :frowning: .