teknoraver / rpms / systemd

Forked from rpms/systemd 2 months ago
Clone

Blame SOURCES/0041-systemctl-Show-how-long-a-service-ran-for-after-it-e.patch

8d419f
From b07519fd5241eacfdb735917eca4ccbf441b5a8a Mon Sep 17 00:00:00 2001
8d419f
From: Daan De Meyer <daan.j.demeyer@gmail.com>
8d419f
Date: Tue, 22 Feb 2022 11:06:00 +0000
8d419f
Subject: [PATCH] systemctl: Show how long a service ran for after it exited in
8d419f
 status output
8d419f
8d419f
(cherry picked from commit 0802f62efc1d1c67d5be67223b529c93536cf2ed)
8d419f
8d419f
Related: #2017035
8d419f
---
8d419f
 src/systemctl/systemctl-show.c | 12 ++++++++++++
8d419f
 1 file changed, 12 insertions(+)
8d419f
8d419f
diff --git a/src/systemctl/systemctl-show.c b/src/systemctl/systemctl-show.c
8d419f
index 37c898f313..9b23471990 100644
8d419f
--- a/src/systemctl/systemctl-show.c
8d419f
+++ b/src/systemctl/systemctl-show.c
8d419f
@@ -433,6 +433,18 @@ static void print_status_info(
8d419f
                                FORMAT_TIMESTAMP_STYLE(until_timestamp, arg_timestamp_style),
8d419f
                                FORMAT_TIMESTAMP_RELATIVE(until_timestamp));
8d419f
                 }
8d419f
+
8d419f
+                if (!endswith(i->id, ".target") &&
8d419f
+                        STRPTR_IN_SET(i->active_state, "inactive", "failed") &&
8d419f
+                        timestamp_is_set(i->active_enter_timestamp) &&
8d419f
+                        timestamp_is_set(i->active_exit_timestamp) &&
8d419f
+                        i->active_exit_timestamp >= i->active_enter_timestamp) {
8d419f
+
8d419f
+                        usec_t duration;
8d419f
+
8d419f
+                        duration = i->active_exit_timestamp - i->active_enter_timestamp;
8d419f
+                        printf("   Duration: %s\n", FORMAT_TIMESPAN(duration, MSEC_PER_SEC));
8d419f
+                }
8d419f
         } else
8d419f
                 printf("\n");
8d419f