summaryrefslogtreecommitdiff
path: root/src/analyze
diff options
context:
space:
mode:
authorBoucman <jeremy.rosen@enst-bretagne.fr>2017-12-05 10:20:40 +0100
committerZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>2017-12-05 10:20:40 +0100
commitbd07d3d0b401b0c837a9b37a9a6aedf0f769fe22 (patch)
tree43e9da8d8eca5607b4b9f6d5465c34b9aeb04324 /src/analyze
parentfc11a1a2041a9050e4aab7fa7bde67f5fd6a3a73 (diff)
downloadsystemd-bd07d3d0b401b0c837a9b37a9a6aedf0f769fe22.tar.gz
Print the time to reach default.target in systemd-analyze time (#7383)
Example output (last line is new): $ systemd-analyze time Startup finished in 12.879s (firmware) + 36.999s (loader) + 1.313s (kernel) + 22.672s (initrd) + 3min 1.755s (userspace) = 4min 15.619s graphical.target reached after 1min 39.377s in userspace
Diffstat (limited to 'src/analyze')
-rw-r--r--src/analyze/analyze.c32
1 files changed, 32 insertions, 0 deletions
diff --git a/src/analyze/analyze.c b/src/analyze/analyze.c
index 5229b3a082..8b220d1978 100644
--- a/src/analyze/analyze.c
+++ b/src/analyze/analyze.c
@@ -491,11 +491,40 @@ static int pretty_boot_time(sd_bus *bus, char **_buf) {
size_t size;
char *ptr;
int r;
+ usec_t activated_time = USEC_INFINITY;
+ _cleanup_free_ char* path = NULL, *unit_id = NULL;
+ _cleanup_(sd_bus_error_free) sd_bus_error error = SD_BUS_ERROR_NULL;
r = acquire_boot_times(bus, &t);
if (r < 0)
return r;
+ path = unit_dbus_path_from_name(SPECIAL_DEFAULT_TARGET);
+ if (!path)
+ return log_oom();
+
+ r = sd_bus_get_property_string(
+ bus,
+ "org.freedesktop.systemd1",
+ path,
+ "org.freedesktop.systemd1.Unit",
+ "Id",
+ &error,
+ &unit_id);
+ if (r < 0) {
+ log_error_errno(r, "default.target doesn't seem to exist: %s", bus_error_message(&error, r));
+ unit_id = NULL;
+ }
+
+ r = bus_get_uint64_property(bus, path,
+ "org.freedesktop.systemd1.Unit",
+ "ActiveEnterTimestampMonotonic",
+ &activated_time);
+ if (r < 0) {
+ log_info_errno(r, "default.target seems not to be started. Continuing...");
+ activated_time = USEC_INFINITY;
+ }
+
ptr = buf;
size = sizeof(buf);
@@ -512,6 +541,9 @@ static int pretty_boot_time(sd_bus *bus, char **_buf) {
size = strpcpyf(&ptr, size, "%s (userspace) ", format_timespan(ts, sizeof(ts), t->finish_time - t->userspace_time, USEC_PER_MSEC));
strpcpyf(&ptr, size, "= %s", format_timespan(ts, sizeof(ts), t->firmware_time + t->finish_time, USEC_PER_MSEC));
+ if (unit_id && activated_time != USEC_INFINITY)
+ size = strpcpyf(&ptr, size, "\n%s reached after %s in userspace", unit_id, format_timespan(ts, sizeof(ts), activated_time - t->userspace_time, USEC_PER_MSEC));
+
ptr = strdup(buf);
if (!ptr)
return log_oom();