ryantimwilson / rpms / systemd

Forked from rpms/systemd a month ago
Clone
9fc0f6
From 29323cff9feac15e1871a10e727690ac0ed1007d Mon Sep 17 00:00:00 2001
9fc0f6
From: Lennart Poettering <lennart@poettering.net>
9fc0f6
Date: Wed, 27 Nov 2013 01:54:25 +0100
9fc0f6
Subject: [PATCH] journald: mention how long we needed to flush to /var in the
9fc0f6
 logs
9fc0f6
9fc0f6
---
9fc0f6
 src/journal/journald-server.c | 11 ++++++++++-
9fc0f6
 1 file changed, 10 insertions(+), 1 deletion(-)
9fc0f6
9fc0f6
diff --git a/src/journal/journald-server.c b/src/journal/journald-server.c
9fc0f6
index e03e413..a0a8e9c 100644
9fc0f6
--- a/src/journal/journald-server.c
9fc0f6
+++ b/src/journal/journald-server.c
9fc0f6
@@ -968,9 +968,12 @@ static int system_journal_open(Server *s) {
9fc0f6
 }
9fc0f6
 
9fc0f6
 int server_flush_to_var(Server *s) {
9fc0f6
-        int r;
9fc0f6
         sd_id128_t machine;
9fc0f6
         sd_journal *j = NULL;
9fc0f6
+        char ts[FORMAT_TIMESPAN_MAX];
9fc0f6
+        usec_t start;
9fc0f6
+        unsigned n = 0;
9fc0f6
+        int r;
9fc0f6
 
9fc0f6
         assert(s);
9fc0f6
 
9fc0f6
@@ -988,6 +991,8 @@ int server_flush_to_var(Server *s) {
9fc0f6
 
9fc0f6
         log_debug("Flushing to /var...");
9fc0f6
 
9fc0f6
+        start = now(CLOCK_MONOTONIC);
9fc0f6
+
9fc0f6
         r = sd_id128_get_machine(&machine);
9fc0f6
         if (r < 0)
9fc0f6
                 return r;
9fc0f6
@@ -1007,6 +1012,8 @@ int server_flush_to_var(Server *s) {
9fc0f6
                 f = j->current_file;
9fc0f6
                 assert(f && f->current_offset > 0);
9fc0f6
 
9fc0f6
+                n++;
9fc0f6
+
9fc0f6
                 r = journal_file_move_to_object(f, OBJECT_ENTRY, f->current_offset, &o);
9fc0f6
                 if (r < 0) {
9fc0f6
                         log_error("Can't read entry: %s", strerror(-r));
9fc0f6
@@ -1050,6 +1057,8 @@ finish:
9fc0f6
 
9fc0f6
         sd_journal_close(j);
9fc0f6
 
9fc0f6
+        server_driver_message(s, SD_ID128_NULL, "Time spent on flushing to /var is %s for %u entries.", format_timespan(ts, sizeof(ts), now(CLOCK_MONOTONIC) - start, 0), n);
9fc0f6
+
9fc0f6
         return r;
9fc0f6
 }
9fc0f6