X-Git-Url: https://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?a=blobdiff_plain;f=src%2Fjournal%2Fjournald-server.c;h=fc8115c31c29922225e004fcffc63b9398f395c8;hb=2d43b190901902dbd98ccea77c1d1ddc9e2a9955;hp=518e9ecc4ef7bf514685d7bcd9d2c57afa4b9e7c;hpb=7ca9dffae1988a885e2e79c4bdca68169f4ca5ff;p=elogind.git diff --git a/src/journal/journald-server.c b/src/journal/journald-server.c index 518e9ecc4..fc8115c31 100644 --- a/src/journal/journald-server.c +++ b/src/journal/journald-server.c @@ -27,10 +27,10 @@ #include #include -#include -#include -#include +#include "sd-journal.h" +#include "sd-messages.h" +#include "sd-daemon.h" #include "fileio.h" #include "mkdir.h" #include "hashmap.h" @@ -38,20 +38,19 @@ #include "socket-util.h" #include "cgroup-util.h" #include "list.h" -#include "virt.h" #include "missing.h" #include "conf-parser.h" +#include "selinux-util.h" #include "journal-internal.h" #include "journal-vacuum.h" #include "journal-authenticate.h" -#include "journald-server.h" #include "journald-rate-limit.h" #include "journald-kmsg.h" #include "journald-syslog.h" #include "journald-stream.h" #include "journald-console.h" #include "journald-native.h" -#include "selinux-util.h" +#include "journald-server.h" #ifdef HAVE_ACL #include @@ -627,6 +626,9 @@ static void dispatch_message_real( } free(c); + } else if (unit_id) { + x = strappenda("_SYSTEMD_UNIT=", unit_id); + IOVEC_SET_STRING(iovec[n++], x); } #ifdef HAVE_SELINUX @@ -971,9 +973,12 @@ static int system_journal_open(Server *s) { } int server_flush_to_var(Server *s) { - int r; sd_id128_t machine; sd_journal *j = NULL; + char ts[FORMAT_TIMESPAN_MAX]; + usec_t start; + unsigned n = 0; + int r; assert(s); @@ -991,6 +996,8 @@ int server_flush_to_var(Server *s) { log_debug("Flushing to /var..."); + start = now(CLOCK_MONOTONIC); + r = sd_id128_get_machine(&machine); if (r < 0) return r; @@ -1010,6 +1017,8 @@ int server_flush_to_var(Server *s) { f = j->current_file; assert(f && f->current_offset > 0); + n++; + r = journal_file_move_to_object(f, OBJECT_ENTRY, f->current_offset, &o); if (r < 0) { log_error("Can't read entry: %s", strerror(-r)); @@ -1053,6 +1062,8 @@ finish: sd_journal_close(j); + 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); + return r; } @@ -1313,17 +1324,14 @@ static int open_signalfd(Server *s) { static int server_parse_proc_cmdline(Server *s) { _cleanup_free_ char *line = NULL; char *w, *state; - int r; size_t l; + int r; - if (detect_container(NULL) > 0) - return 0; - - r = read_one_line_file("/proc/cmdline", &line); - if (r < 0) { + r = proc_cmdline(&line); + if (r < 0) log_warning("Failed to read /proc/cmdline, ignoring: %s", strerror(-r)); + if (r <= 0) return 0; - } FOREACH_WORD_QUOTED(w, l, line, state) { _cleanup_free_ char *word;