richardphibel / rpms / systemd

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