Products › lamco-dbus-tools › Docs
Keep the last minutes of D-Bus traffic with dbuskeep
Keep the last minutes of D-Bus traffic with dbuskeep, for a user or for the system bus, so a recording can start from what happened before it was asked for.
Describes version 0.4.1.
dbuskeep keeps the last minutes of a bus with one monitor, so a problem can be looked at after it
happened, and every program that records the whole bus reads through it instead of adding a monitor of its
own. Nothing needs it.
For yourself
dbuskeep run
Or as a user service, which starts with each login:
cp packaging/systemd/user/dbuskeep.service ~/.config/systemd/user/
systemctl --user daemon-reload
systemctl --user enable --now dbuskeep
--window <seconds> is how much it keeps, 300 by default, and --held-cap <MiB> the most of it it
holds, 64 by default, the oldest let go first.
What it holds
$ dbuskeep status
dbuskeep 0.1.0 (process 1415) keeps bus ad8eaf635ca1b6adaa2f221dc1522a85 (session), at /run/user/1000/lamco-dbus-tools/keep/ad8eaf635ca1b6adaa2f221dc1522a85.sock: 1014 messages, 470618 bytes, the oldest from 1.99 s ago; 1014 read since it began, 0 readers now.
The last minutes, now
dbussee record --all --ring 60 --now --after 0 --out last-minute.json
With the service, this returns at once with the last minute it kept: On Fedora 45's session bus, 2,334
messages in half a second. Without it, --now has only what came since the recording began. Every lens
reads the capture as any other, and its monitor record names the service.
--no-keep records with the command's own monitor, service or not.
One service, or one rule, from what it kept
Rules go through the service too, which applies them as the bus would:
dbussee record --match "interface='org.freedesktop.Notifications'" --ring 60 --now --after 0 --out notes.json
dbussee watch --match "type='error'"
The ring returns at once with the last minute's matching messages, and the capture's monitor record says
filtered_by the service. On dbus-broker, a destination in a rule is never applied, by the bus or the
service, so --service NAME, which asks for sender='NAME' and destination='NAME', takes every message
there (match rules); the recording says so before it begins, and its capture gives
BUS-004. With the service running, --rules-as-specified has it apply the rules as the specification reads
them, so --service NAME takes that service's own traffic:
dbussee record --service org.freedesktop.Notifications --rules-as-specified --duration 30 --out notes.json
For the system bus
sudo install -m 755 target/release/dbuskeep /usr/bin/dbuskeep
sudo cp packaging/systemd/system/dbuskeep.service /etc/systemd/system/
sudo systemctl daemon-reload
sudo systemctl enable --now dbuskeep
It runs as root, which alone may monitor the system bus, and answers root and the group
lamco-dbus-monitor:
sudo groupadd -f lamco-dbus-monitor
sudo usermod -aG lamco-dbus-monitor "$USER" # then log in again
dbussee --bus system record --all --ring 60 --now --after 0 --out system.json
A member of the group then records the system bus with no helper installed and no privilege of their own: On Fedora 45, 553 messages in a quarter of a second. Anyone else is refused with the reason: That the process isn't in the group, or that the machine hasn't got it, as on Fedora before the group was made:
dbuskeep status: the service at /run/lamco-dbus-tools/keep/4e28e41fc0c85925b3440186ece348d1.sock refused: the system service answers root and the group lamco-dbus-monitor, which this machine hasn't got
The group is the one dbussee-monitor trusts, so the service gives no one a reading they couldn't already
have taken.
On dbus-daemon before 1.16.4 the system's service refuses to start, as dbussee record does on that bus,
because of the flaw BUS-003 names. Add --accept-known-flaw to its command line with systemctl edit
dbuskeep once that's been decided. A command that's slow the first time
runs it so on Debian 13 and finds a start three seconds after it happened.
The service reference has the socket, the requests and the rules.