Products › lamco-dbus-tools › Docs

Record D-Bus traffic: One service, a match rule or a whole bus

Record D-Bus traffic with dbussee record: One service, a match rule or a whole bus, as a document, a stream or a ring, with a pcapng file for Wireshark.

Describes version 0.4.1.

dbussee record listens to a bus and keeps each message. watch shows them as they pass, and pending shows what's left waiting. All three take the same flags for what to listen to, and all refuse to run without one: Listening to everything costs the bus a copy of every message.

Each recording starts with a snapshot, of the bus and of who owns which name, on a connection of its own. Then a second connection becomes the monitor. Doing no harm says what that costs the bus, measured, and what guards the recorder has.

One service, both ways

dbussee record --service org.freedesktop.Notifications --duration 30 --out notify.json
dbustell health notify.json

--service takes what the service sends and what's sent to it. Give it more than once for several services. On dbus-broker, a rule on a destination costs the bus about as much as recording everything, so where the cost matters there, take what the service sends with a rule of your own:

dbussee record --match "sender='org.freedesktop.Notifications'" --duration 30 --out notify.json

By rule, or everything

dbussee record --match "type='signal',interface='org.freedesktop.DBus.Properties'" --out props.json
dbussee record --all --duration 5 --out everything.json

A rule is sent to the bus as written, and only its form is checked first. One the bus refuses comes back as the bus's own error.

What of each body to keep

A body can hold a password, a keyring item or the text of a notification, so it's kept as its length unless more is asked for:

--bodies Keeps
length (the default) The length
hash The length and a SHA-256, which tells two bodies apart and says nothing of either
decoded The values
raw The bytes, in the byte order the message states

The bus's own owner changes are always decoded: They hold only names.

A long recording

A recording kept as one document holds every record in memory until it ends, about 3.7 KiB a message, and stops at 20,000 messages unless --max-messages says otherwise. For anything long, write it as a stream:

dbussee record --all --stream --duration 0 --size-cap 500 --out session.jsonl

A stream is written as it's taken, a line for each record, and its memory doesn't grow. --duration 0 is no time limit. It ends at its size cap (1024 MiB unless told), at Ctrl-C or SIGTERM, when the file named with --until-file appears, or at Ctrl-Z, which ends it rather than stopping it. Its last line says how it ended. A stream a kill left without its last line is still read, as far as it goes, and every dbustell command reads a stream as it reads a document.

Catch a problem that comes and goes

A ring keeps only the last seconds and writes them when something worth keeping happens:

dbussee record --all --ring 120 --on-error --on-pending 5000 --duration 0 --out caught.json

It fires on an error reply (--on-error, or --on-error=NAME for one error), on a call that has waited --on-pending milliseconds for its reply, or when it's sent SIGUSR1:

pkill -USR1 -x dbussee

It then records --after seconds more (5 unless told) and ends, with what led up to the trigger and what followed it, and the ring's own record saying what fired it. A ring that never fires exits 1, having kept nothing.

Watch it happen

dbussee watch --service org.freedesktop.portal.Desktop
dbussee watch --all --bodies decoded --duration 10

It prints a line for each message: Its time since the start, its type, who sent it to whom, and what it is. The lines go to standard output and how it ended to standard error, so it pipes cleanly:

dbussee watch --all | grep -i error
dbussee --json watch --all | jq -c .record.payload

What's stuck

dbussee pending --all

It listens for five seconds, then shows each call still waiting for a reply, how long it had waited and who it waits on, and which callers wait on a caller that's itself waiting:

After listening 5 s to 412 messages, 2 calls were waiting for a reply:

      4.21 s  :1.42 caller (1834) -> com.example.Relay (:1.7 relay (2290))
              com.example.Relay.Relay on /relay, serial 12
      ...

Who waits on whom:
  :1.42 caller (1834) -> :1.7 relay (2290) -> :1.9 echo (2301)

It can't see a call made before it began listening, and a call whose reply its rules didn't take looks as if it waits. --service and --all take replies.

For Wireshark, busctl and dbus-monitor

--pcap writes each message's bytes, exactly as the bus sent them, to a pcapng file beside the capture. Each record names its packet:

dbussee record --all --duration 10 --pcap session.pcapng --out session.json
wireshark session.pcapng

A capture recorded with raw bodies can be written out later:

dbussee record --all --bodies raw --out session.json
dbustell export session.json --out session.pcapng

Files other tools wrote can be read in too, then read like any capture:

busctl capture > busctl.pcapng          # pcapng
dbus-monitor --pcap > monitor.pcap      # classic pcap
dbustell import busctl.pcapng --bodies decoded --out busctl.json
dbustell health busctl.json

An imported capture has the messages and nothing else: No snapshot of the bus, and its stamps are the writing tool's wall clock, which can jump. The toolkit's own capture stays the source of truth.

A system bus

Listening to a system bus needs root on most machines, and without it the bus refuses and record exits 1. On a dbus-daemon older than 1.16.4, which Debian 13 ships, record refuses to attach a privileged monitor to a system bus at all, because an unprivileged user could crash the bus while one is attached, unless given --accept-known-flaw. A distribution may have patched the flaw without changing the version. The helper lets a member of one group record the system bus without running the whole tool as root: Recording the system bus.

A recorder that can't hold up the bus

dbussee record --all --helper --duration 60 --out rec.json

--helper has dbussee-monitor become the monitor in a process of its own, read the bus and pass each message on through a pipe. If the recorder is stopped, by SIGSTOP, a debugger or a slow disk, the helper keeps reading, and when more than its budget waits it detaches itself rather than let the bus's queue for it grow. The capture's monitor record names the helper and its process. On a private bus on 2026-12-02, a recorder with --helper was stopped while 3,000 signals were sent, then let go: It recorded everything, up to its 20,000-message cap, and ended normally. For the system bus without root it's on by itself.

When it ends early

What it says What happened
Stopped: the duration ran out and the other ways it was asked to stop It did its job. Exit 0
detached itself at message N More than its budget waited to be written, so it closed its own connection before the bus could act. The capture is whole up to message N. Exit 1
the bus closed the connection The bus cut it off: Under SIGSTOP or a debugger, which --helper guards against. Exit 1
Nothing kept: No trigger fired A ring that never fired. Exit 1