Inspiration

There is no telemetry collector for QNX.

On Linux, getting telemetry off a machine is an install away: Telegraf, collectd, Fluent Bit, the OpenTelemetry Collector, a Prometheus exporter. Run one, and the system and the applications on it report what they're doing, all the time, to wherever you keep that data.

On QNX we found nothing like it, and we checked: QNX's package repository for 8.0, about 3,500 packages, has none of those agents, and neither do the 239 projects in the qnx-ports organization. What QNX does have are its own tools, and they're excellent: tracelogger, the System Profiler, pidin. But they're troubleshooting tools you run on demand, when something already went wrong. Nothing reports, automatically and continuously, what the system and the applications and servers running on it are doing. So the most interesting data on a QNX system, when each thread ran and what got in its way, usually never leaves the device.

We already had a collector. rtcollector started in May 2025 as a side project, before Basekick Labs even existed: a small Telegraf-style agent in Python, written to play with RedisTimeSeries. It later moved to the Basekick Labs organization, and we're planning to rewrite it in Go. Neither Python nor Go fit a real-time system: an interpreter or a garbage collector can pause, allocate or take the CPU at the wrong moment. So for the QNX Global Hackathon we built a new one in C, for QNX 8.0, keeping rtcollector's configuration and plugin model, around one rule:

The collector must never be the reason a deadline is missed.

What it does

rtcollector for QNX runs on the device and sends what it is doing to Arc, our open-source columnar database for time-series data, or to any MQTT broker:

  • Scheduling latency per thread, from the kernel trace. For every thread that wakes up: how long it waited between becoming ready and running (p50, p99, max), how often it woke, how long it ran, how often it was preempted. Plus context switches and interrupts per CPU, and interrupts per vector.
  • CPU usage per core, memory, processes and threads, read the QNX way.
  • Your own metrics, through a device file. rtcollector registers /dev/rtcollector as a QNX resource manager. Any program publishes a metric by writing one line to it: no library to link, no socket.
  int fd = open("/dev/rtcollector", O_WRONLY);
  rtc_publish(fd, "control_loop,axis=x jitter_us=%di", jitter);
  • Its own health: every record it drops, and why, is counted and reported like any other metric.

In Arc it's all SQL: which threads waited longest in the last hour, and at what priority?

SELECT process, thread, MAX(priority) AS prio, SUM(wakeups) AS wakeups,
       MAX(latency_max_ns) AS worst_ns
FROM sched GROUP BY process, thread ORDER BY worst_ns DESC LIMIT 10;

It ships as a single binary for the Raspberry Pi 4 (aarch64le) and for QEMU (x86_64): download it, copy it to the device, run it. Nothing to compile.

How we built it

C11 and the QNX SDP 8.0. The code is split in two. A portable core (configuration, buffers, the MessagePack encoder, the line-protocol parser, the scheduling model) builds with any C compiler and is unit-tested on Linux and macOS in CI, with AddressSanitizer and UndefinedBehaviorSanitizer. The QNX layer (the resource manager, the trace input, the system inputs) builds with qcc and is tested on a QEMU virtual machine and on a Raspberry Pi 4.

Staying out of the way. Buffers are allocated once, at start. A write() to /dev/rtcollector copies the bytes into a preallocated ring and returns: no allocation, no I/O, no logging, no lock the sender can hold. Parsing happens later, on a collection thread below the application's real-time priorities; the network sender runs lowest. When a buffer is full, data is dropped and counted. The collector never waits.

CPU without /proc/stat. QNX doesn't have one. Each core has an idle thread inside the kernel process, so the usage of core $i$ over an interval $\Delta t$ is

$$ U_i = 1 - \frac{\Delta T_{\text{idle},i}}{\Delta t} $$

Latency from the kernel trace. The collector runs its own trace session through libtracelog and decodes each trace file with libtraceparser. For each thread, the latency of a wakeup is $L = t_{\text{running}} - t_{\text{ready}}$, aggregated per interval into p50, p99 and max.

A release a judge can run. The QNX SDP can't run on GitHub's runners, so the release workflow sends the source over Tailscale to our own build host, which builds both architectures as an unprivileged user and checks that the binaries need only libraries the QNX images already have. The workflow verifies the result and publishes the binaries with checksums.

Built with AI, checked by measurement. Most of the C was written with Claude Code, against QNX's documentation. Every claim about timing was checked by measurement on the device, and the two biggest bugs below were found that way.

Challenges we ran into

Latencies that weren't there. The first numbers from the Pi looked wrong: on an idle four-core board, a priority-254 thread showed waits of 50 ms, and network threads 215 ms, almost always whole multiples of 5 ms. Those multiples were the clue: they were the periods of the threads that showed them. QNX writes trace events into a separate buffer per CPU, and the buffers reach the trace file as they fill. A thread that wakes on one CPU and runs on another has its "ready" in one buffer and its "running" in another, and they arrived out of order, so we paired a "ready" with the next period's "running". The fix: collect each file's events, sort them by time, and apply them only up to the newest time every CPU has reached; the rest waits for the next file. On the same Pi, the worst wait went from 215 ms to 0.3 ms.

The device file made a fast writer wait. Our first resource manager had one dispatch thread and used priority inheritance, the textbook choice. Tracing it with tracelogger showed two problems. In QNX 8, a sender preempted in the middle of its send keeps the server thread reserved: a priority-5 writer interrupted by a priority-30 CPU hog held up a priority-50 writer for 20 to 47 ms. And with priority inheritance, a low writer's handler ran at that writer's low priority, so anything in between could preempt it. Now the device has a pool of four dispatch threads, each with its own buffer, on a channel with a fixed priority above every writer: in the same test, the worst write took 43 µs.

A board with no clock. A Raspberry Pi has no clock that survives power-off; QNX boots in 1970, and the collector drops rows stamped before its own build date (and counts them). The image sets the clock with ntpdate when it gets a network lease; we added our own to be safe. Two ntpdate runs from 1970 at once added their steps, and the Pi woke up in 2083, sending data from the future. The start script now waits for the image's own clock set, sets it only if nobody else is, and steps it once more to undo a doubled step.

A library we can't ship. Decoding the trace needs QNX's libtraceparser, which we can't redistribute. The collector loads it at run time, from the system or from next to the binary, and refuses a copy that someone other than root (or the user running it) could have changed. Without it, every other input still runs.

One write per character. QNX's dprintf sends literal text one character per write(), which turns one metric into dozens of messages. rtc_publish.h formats into a stack buffer and sends a single write.

Accomplishments that we're proud of

  • A telemetry collector for QNX: system and application telemetry, reported continuously, where there was none.
  • Scheduling latency that is right across CPUs. A collector that invents latency is worse than none, and we found and fixed the case where ours did.
  • About 3% of one core on an idle Raspberry Pi 4, with every input on, one-second rounds, about 43 rows a second to Arc and about 1 MB a second of kernel trace decoded.
  • Writes to /dev/rtcollector that cost one memory copy, and every dropped record counted.
  • A release anyone can run without compiling, a getting-started guide from a blank SD card to data in Arc, and a path for QEMU when there is no Pi.

What we learned

  • Arrival order is not time order. On a multi-core QNX system, kernel trace events must be merged across CPUs before they mean anything.
  • The textbook answer needs a trace. Priority inheritance sounded right for a device file written by real-time threads; tracing showed where it wasn't, and QNX 8's behaviour when a sender is preempted mid-send changed our design.
  • Measure on the device. Every serious bug we found only showed up on real hardware: unit tests and emulators didn't see out-of-order buffers, a missing clock or a preempted sender.
  • Count every drop. Under load a collector has to give something up. Doing it on purpose, and saying so, is what makes the rest of the data trustworthy.

What's next for rtcollector for QNX

That's up to you. We can't wait to see what you monitor with rtcollector on QNX and Arc: control loops, robots, test rigs, whatever runs on your QNX systems, and how much more observable it makes them. Try the release, and tell us what you found, or open an issue on GitHub.

Built With

  • arc
  • c
  • docker
  • github
  • github-actions
  • libcurl
  • libtracelog
  • libtraceparser
  • libyaml
  • messagepack
  • mqtt
  • qemu
  • qnx-8.0
  • qnx-sdp-8.0
  • raspberry-pi-4
  • tailscale
  • zstd
Share this project:

Updates

Submission history