libqiftop is the Qt6::Core-only shared library that carries everything
qiftop knows about network traffic except the GUI. It exists so the same
data plane can feed many frontends and tools — not just the Qt app.
It ships as two packages:
| Package (deb / rpm) | Contents |
|---|---|
libqiftop0 / qiftop-libs |
the runtime .so (SONAME libqiftop.so.0) |
libqiftop-dev / qiftop-devel |
headers, CMake config, pkg-config |
No Qt Widgets dependency, so it runs headless (over SSH, in a container, in
a daemon). qiftop (GUI) and qiftop-agent both link it.
┌─────────────── libqiftop ───────────────┐
qiftop-agent ──DBus──▶ DBusNetworkMonitor InterfaceAggregator ─┐
(system bus) DBusConnectionMonitor ConnectionAggregator │
(source) (batch + stream) │
│ │
util/ConnectionFilter ◀──────┤ consumer
util/Units (IEC fmt) │ (your code)
util/Exporter (JSON/CSV) ◀────┘ │
dbus/Types (DTOs / wire) ───────────────────┘
- Source —
DBus{Network,Connection}Monitorsubscribe to the agent'sorg.qiftop.NetworkAgent1signals and re-emitstatsUpdated/connectionsUpdated. (The privileged in-process capture path —backend/linux— is not shipped in the lib; consumers stream from the agent. That keeps libqiftop unprivileged and platform-agnostic.)DBusConnectionMonitoralso re-emits the agent's deep-passAttributionChangedpatches onconnectionsAttributionRefined(an attribution-only delta — feed it to the aggregator, never into rate math), and exposessetDesiredAttributionEagerness()/attributionEagernessChanged()so a consumer can dial the agent's runtime attribution effort (both gated on theattribution-eagerness-hints/attribution-async-refinementcapability tokens; no-ops otherwise). - Aggregators —
InterfaceAggregator/ConnectionAggregatorare plainQObjects that own the derived view: per-interface and per-flow rates, the 3-layer EMA rate-smoothing pipeline, UDP peer-aggregation, direction inference, the adaptive throughput reference, DNS hostnames, stale-flow retention. They are simultaneously:- batch — query
rows()/rowAt(i)for the current snapshot; - stream — connect to their change signals (
rowsChanged,rowsUpdated,rowsInserted/Removed,didReset) for deltas.ConnectionAggregator::applyAttributionPatch()applies a deep-pass refinement (wire it to the monitor'sconnectionsAttributionRefined) so process/container/chain/reason update in place without disturbing rates.
- batch — query
- Filter —
qiftop::filter(theproto:tcp and rate_total>1Mmini-language) evaluates against aContextbuilt from aConnection, so any consumer can filter without re-implementing the grammar. - Format —
util::Exporterserialises anyExportable(the models, or your own) to JSON / CSV with the security hardening (CSV formula injection, quint64-as-string) baked in.util::formatBytes/formatByteRategive the IEC unit strings. - DTOs —
dbus/Types.his the wire contract; consumers that talk to the agent directly (or replay captures) use the same structs.
The whole pattern is "source → aggregator → serialise", on a
QCoreApplication event loop. See examples/ndjson-stream/ for a ~100-line
consumer that turns the agent's live stream into NDJSON on stdout:
auto *mon = new DBusNetworkMonitor(/*session=*/false, &app);
auto *agg = new InterfaceAggregator(&app);
QObject::connect(mon, &NetworkMonitor::statsUpdated,
agg, &InterfaceAggregator::updateStats);
QObject::connect(agg, &InterfaceAggregator::rowsChanged, &app, [agg]{
/* serialise agg->rows() to NDJSON / Prometheus / an alert rule */
});
mon->start();Build against it with either:
find_package(qiftop REQUIRED)
target_link_libraries(my_tool PRIVATE qiftop::qiftop)or pkg-config --cflags --libs qiftop.
The facility is designed so each of these is a thin consumer, not a fork.
Shipped examples live under examples/ (standalone
find_package(qiftop) projects):
- NDJSON / line-oriented CLI —
examples/ndjson-stream(interfaces) andexamples/ndjson-connections(per-flow, with process/container attribution). Pipe live data intojq, a log shipper,awk, etc.;--oncegives a batch snapshot for cron/scripts. - Prometheus / OpenMetrics exporter —
examples/prometheus-exporter: serves/metrics(interface byte counters + per-container/process rate gauges) so alerting ("incessantly hogging" via a PromQLfor:clause) is delegated to Prometheus/Alertmanager — no new ecosystem to learn. - Snapshot export —
examples/snapshot-export: one-shot CSV/JSON dump of the current flow table viautil::exporter. - Top-talkers CLI —
examples/top-talkers: a headlessiftop -t-style printer over the aggregator + IEC rate formatter. - Alerting daemon (planned) — evaluate the filter mini-language against
the stream; fire on
rate_total>X, a new container talking out, etc. See the v0.3 alerting design. - Language bindings — Python / Rust over a future stable C ABI
(
extern "C"shim) wrapping the DTOs + aggregators. Deferred, but the library is kept binding-friendly (plain value types, no Widgets). - Embedding — any Qt app that wants live traffic data without the qiftop UI links the aggregators directly.
- Alternative frontends — the ncurses
nqiftopis the first non-Qt-Widgets frontend; it reuses the aggregators wholesale.
Pre-1.0 the ABI is unstable — the CMake find_package config requires
an exact version match, and the SONAME is libqiftop.so.0. The durable
cross-process contract is the DBus wire format (org.qiftop.NetworkAgent1,
see AGENTS.md §4), not the C++ ABI. Treat the C++ API as "recompile your
consumer against each qiftop release" until 1.0.
The pure-logic subset (DTOs, the filter mini-language, unit formatters, the
aggregation/EMA helpers) has no Network/DBus dependency and is kept in a
self-contained seam so it can graduate to a separate libqiftop-core
package if a consumer wants the logic without the DBus client (e.g. a
/proc-reading exporter, or pure bindings). Not split today — the current
consumers all want the full source→aggregate→format stack.