Products › lamco-dbus-tools › Docs
Time a D-Bus service start, and see why one failed
Time a D-Bus service start and see why one failed: dbustell activation joins the journal to the messages, from the request to the name taken, on both buses.
Describes version 0.4.1.
A recording reads the journal for its own span once it has stopped listening, so it holds what the bus
and the service manager said about each start. dbustell activation joins that to the messages.
dbussee record --all --duration 20 --out start.json
# start the service meanwhile, by calling it or with busctl call ... StartServiceByName
dbustell activation start.json
For each start it gives who asked and how, then:
- Started: When the bus or the service manager began it, after the request. That's journald's receipt of the line, on the same machine's monotonic clock, and holds however long journald took to receive it. The request is stamped when the recorder read it, which can be later than the bus logged the start: Then the line reads "started 5.57 ms before the recorder read the request, which it read late". A line is taken as the start from up to 100 ms before its request, never from before an earlier request for the same name.
- Name taken: When the service took its bus name, after the request, on the recorder's own clock. Its uncertainty is the longest the bus took to answer a call to itself in that recording, which it answers at once. Measured on both buses with a service that waits a second, it came within 2 ms of the test's own figure.
- Failed: In the words of whoever logged it. dbus-daemon starts the service itself and logs its own
reason, such as
Process com.example.WontStart exited with status 3. dbus-broker has the service manager start it, which logs the exit, such asMain process exited, code=exited, status=3/NOTIMPLEMENTED. - What the service wrote: Its own lines in the journal, by its bus name or its unit.
- Who started it: dbus-daemon itself, dbus-broker's launcher in a unit of its own making, or the service manager in the unit the service file names; and a unit the service manager has for the name, when the start went around it.
- After: A caller that left before the name was taken, and changes to the activation environment after it, by the variables' names.
The findings
dbustell findings turns these into ACT- findings, each shown on both buses from a recording that holds
it:
| Finding | When |
|---|---|
ACT-001 |
A start failed, with the reason as it was logged |
ACT-002 |
A start took a second or more, from the request to the name being taken |
ACT-003 |
A call asked for a name nothing provides, and the bus answered ServiceUnknown |
ACT-004 |
The caller left before the name it asked for was taken |
ACT-005 |
The activation environment changed after a service had started, so it runs without what was set |
ACT-006 |
A service was started outside the unit the service manager has for it |
A service started too early works through ACT-005 on a real session, and
a desktop service that's slow to appear through ACT-002, with a unit whose name isn't the bus
name's: The unit dbus-daemon names in its line, unit='...', is the one followed, its lines kept and its state
read.
A recording made with --no-host holds no journal, and then only the request and the name being taken are
known.
Without recording
dbussee journal --since 30m
It gives the bus's and the service manager's lines of the last half hour, and what the services the bus started wrote. A user who may not read the system's journal sees only their own lines.
What's stuck in a queue
dbussee stats --count 10 --every 0.5
dbussee record --all --stats 1 --duration 60 --out rec.json
It polls the bus's own counters: For each connection, what the bus held for it to read. A program that stops reading
shows here as a queue that grows, and dbustell findings names it as NAME-005. The counters can't name a
monitor, which gives up its unique name. --top N shows the N connections that held the most; one poll of a
private bus with the lamp of changing a service's state on it
(docs/measurements/stage-13/flags/):
$ dbussee stats --count 1 --top 3
1 polls over 0 ns, asked with GetStats, and GetConnectionStats for each connection. What the bus held for each connection to read: The most at any poll, at the last, and the most ever since it joined,
CONNECTION MOST LAST EVER NOTE
:1.3 0 B 0 B 488 B
:1.1 (com.example.Lamp) 0 B 0 B 181 B
A refused call
dbustell errors puts each AccessDenied the bus sent beside dbus-daemon's own Rejected send message line
about it, which names the policy's decision. dbus-broker refused the same call, by its policy file, in the
tests and logged nothing the lens found.
A refusal SELinux decides is logged by both buses: dbus-broker's line, and SELinux's access vector record
beside it. errors puts both beside the refusal, as on Fedora 44 with a socket labelled as the print service
calling logind (docs/measurements/selinux-refusal/):
1 org.freedesktop.DBus.Error.AccessDenied, answering org.freedesktop.login1 org.freedesktop.DBus.Peer.Ping
the bus logged: A security policy denied :1.102 to send method call /org/freedesktop/login1:org.freedesktop.DBus.Peer.Ping to org.freedesktop.login1.
SELinux denied send_msg from system_u:system_r:cupsd_t:s0 to system_u:system_r:systemd_logind_t:s0