summaryrefslogtreecommitdiff
path: root/src/journal
diff options
context:
space:
mode:
Diffstat (limited to 'src/journal')
-rw-r--r--src/journal/.gitignore3
-rw-r--r--src/journal/journald-gperf.gperf27
-rw-r--r--src/journal/journald.c75
-rw-r--r--src/journal/journald.h74
-rw-r--r--src/journal/systemd-journald.conf21
5 files changed, 161 insertions, 39 deletions
diff --git a/src/journal/.gitignore b/src/journal/.gitignore
index faf48e7dc3..d6a79460cd 100644
--- a/src/journal/.gitignore
+++ b/src/journal/.gitignore
@@ -1 +1,2 @@
-libsystemd-journal.pc
+/journald-gperf.c
+/libsystemd-journal.pc
diff --git a/src/journal/journald-gperf.gperf b/src/journal/journald-gperf.gperf
new file mode 100644
index 0000000000..ace373ba47
--- /dev/null
+++ b/src/journal/journald-gperf.gperf
@@ -0,0 +1,27 @@
+%{
+#include <stddef.h>
+#include "conf-parser.h"
+#include "journald.h"
+%}
+struct ConfigPerfItem;
+%null_strings
+%language=ANSI-C
+%define slot-name section_and_lvalue
+%define hash-function-name journald_gperf_hash
+%define lookup-function-name journald_gperf_lookup
+%readonly-tables
+%omit-struct-type
+%struct-type
+%includes
+%%
+Journal.RateLimitInterval, config_parse_usec, 0, offsetof(Server, rate_limit_interval)
+Journal.RateLimitBurst, config_parse_unsigned, 0, offsetof(Server, rate_limit_burst)
+Journal.Compress, config_parse_bool, 0, offsetof(Server, compress)
+Journal.SystemMaxUse, config_parse_bytes, 0, offsetof(Server, system_metrics.max_use)
+Journal.SystemMaxFileSize, config_parse_bytes, 0, offsetof(Server, system_metrics.max_size)
+Journal.SystemMinFileSize, config_parse_bytes, 0, offsetof(Server, system_metrics.min_size)
+Journal.SystemKeepFree, config_parse_bytes, 0, offsetof(Server, system_metrics.keep_free)
+Journal.RuntimeMaxUse, config_parse_bytes, 0, offsetof(Server, runtime_metrics.max_use)
+Journal.RuntimeMaxFileSize, config_parse_bytes, 0, offsetof(Server, runtime_metrics.max_size)
+Journal.RuntimeMinFileSize, config_parse_bytes, 0, offsetof(Server, runtime_metrics.min_size)
+Journal.RuntimeKeepFree, config_parse_bytes, 0, offsetof(Server, runtime_metrics.keep_free)
diff --git a/src/journal/journald.c b/src/journal/journald.c
index b029ab9781..68c1c23cdf 100644
--- a/src/journal/journald.c
+++ b/src/journal/journald.c
@@ -43,6 +43,8 @@
#include "sd-journal.h"
#include "sd-login.h"
#include "journal-internal.h"
+#include "conf-parser.h"
+#include "journald.h"
#define USER_JOURNALS_MAX 1024
#define STDOUT_STREAMS_MAX 4096
@@ -56,40 +58,6 @@
#define SYSLOG_TIMEOUT_USEC (5*USEC_PER_SEC)
-typedef struct StdoutStream StdoutStream;
-
-typedef struct Server {
- int epoll_fd;
- int signal_fd;
- int syslog_fd;
- int native_fd;
- int stdout_fd;
-
- JournalFile *runtime_journal;
- JournalFile *system_journal;
- Hashmap *user_journals;
-
- uint64_t seqnum;
-
- char *buffer;
- size_t buffer_size;
-
- JournalRateLimit *rate_limit;
-
- JournalMetrics runtime_metrics;
- JournalMetrics system_metrics;
-
- bool compress;
-
- uint64_t cached_available_space;
- usec_t cached_available_space_timestamp;
-
- uint64_t var_available_timestamp;
-
- LIST_HEAD(StdoutStream, stdout_streams);
- unsigned n_stdout_streams;
-} Server;
-
typedef enum StdoutStreamState {
STDOUT_STREAM_TAG,
STDOUT_STREAM_PRIORITY,
@@ -1761,6 +1729,32 @@ static int open_signalfd(Server *s) {
return 0;
}
+static int server_parse_config_file(Server *s) {
+ FILE *f;
+ const char *fn;
+ int r;
+
+ assert(s);
+
+ fn = "/etc/systemd/systemd-journald.conf";
+ f = fopen(fn, "re");
+ if (!f) {
+ if (errno == ENOENT)
+ return 0;
+
+ log_warning("Failed to open configuration file %s: %m", fn);
+ return -errno;
+ }
+
+ r = config_parse(fn, f, "Journal\0", config_item_perf_lookup, (void*) journald_gperf_lookup, false, s);
+ if (r < 0)
+ log_warning("Failed to parse configuration file: %s", strerror(-r));
+
+ fclose(f);
+
+ return r;
+}
+
static int server_init(Server *s) {
int n, r, fd;
@@ -1770,9 +1764,14 @@ static int server_init(Server *s) {
s->syslog_fd = s->native_fd = s->stdout_fd = s->signal_fd = s->epoll_fd = -1;
s->compress = true;
+ s->rate_limit_interval = DEFAULT_RATE_LIMIT_INTERVAL;
+ s->rate_limit_burst = DEFAULT_RATE_LIMIT_BURST;
+
memset(&s->system_metrics, 0xFF, sizeof(s->system_metrics));
memset(&s->runtime_metrics, 0xFF, sizeof(s->runtime_metrics));
+ server_parse_config_file(s);
+
s->user_journals = hashmap_new(trivial_hash_func, trivial_compare_func);
if (!s->user_journals) {
log_error("Out of memory.");
@@ -1846,7 +1845,7 @@ static int server_init(Server *s) {
if (r < 0)
return r;
- s->rate_limit = journal_rate_limit_new(DEFAULT_RATE_LIMIT_INTERVAL, DEFAULT_RATE_LIMIT_BURST);
+ s->rate_limit = journal_rate_limit_new(s->rate_limit_interval, s->rate_limit_burst);
if (!s->rate_limit)
return -ENOMEM;
@@ -1916,15 +1915,15 @@ int main(int argc, char *argv[]) {
if (r < 0)
goto finish;
+ server_vacuum(&server);
+ server_flush_to_var(&server);
+
log_debug("systemd-journald running as pid %lu", (unsigned long) getpid());
sd_notify(false,
"READY=1\n"
"STATUS=Processing requests...");
- server_vacuum(&server);
- server_flush_to_var(&server);
-
for (;;) {
struct epoll_event event;
diff --git a/src/journal/journald.h b/src/journal/journald.h
new file mode 100644
index 0000000000..47feca40aa
--- /dev/null
+++ b/src/journal/journald.h
@@ -0,0 +1,74 @@
+/*-*- Mode: C; c-basic-offset: 8; indent-tabs-mode: nil -*-*/
+
+#ifndef foojournaldhfoo
+#define foojournaldhfoo
+
+/***
+ This file is part of systemd.
+
+ Copyright 2011 Lennart Poettering
+
+ systemd is free software; you can redistribute it and/or modify it
+ under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
+
+ systemd is distributed in the hope that it will be useful, but
+ WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with systemd; If not, see <http://www.gnu.org/licenses/>.
+***/
+
+#include <inttypes.h>
+#include <sys/types.h>
+#include <stdbool.h>
+
+#include "journal-file.h"
+#include "hashmap.h"
+#include "util.h"
+#include "journal-rate-limit.h"
+#include "list.h"
+
+typedef struct StdoutStream StdoutStream;
+
+typedef struct Server {
+ int epoll_fd;
+ int signal_fd;
+ int syslog_fd;
+ int native_fd;
+ int stdout_fd;
+
+ JournalFile *runtime_journal;
+ JournalFile *system_journal;
+ Hashmap *user_journals;
+
+ uint64_t seqnum;
+
+ char *buffer;
+ size_t buffer_size;
+
+ JournalRateLimit *rate_limit;
+ usec_t rate_limit_interval;
+ unsigned rate_limit_burst;
+
+ JournalMetrics runtime_metrics;
+ JournalMetrics system_metrics;
+
+ bool compress;
+
+ uint64_t cached_available_space;
+ usec_t cached_available_space_timestamp;
+
+ uint64_t var_available_timestamp;
+
+ LIST_HEAD(StdoutStream, stdout_streams);
+ unsigned n_stdout_streams;
+} Server;
+
+/* gperf lookup function */
+const struct ConfigPerfItem* journald_gperf_lookup(const char *key, unsigned length);
+
+#endif
diff --git a/src/journal/systemd-journald.conf b/src/journal/systemd-journald.conf
new file mode 100644
index 0000000000..f137ab8833
--- /dev/null
+++ b/src/journal/systemd-journald.conf
@@ -0,0 +1,21 @@
+# This file is part of systemd.
+#
+# systemd is free software; you can redistribute it and/or modify it
+# under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+# See system-journald.conf(5) for details
+
+[Journal]
+#Compress=yes
+#RateLimitInterval=10s
+#RateLimitBurst=200
+#SystemMaxUse=
+#SystemKeepFree=
+#SystemMaxFileSize=
+#SystemMinFileSize=
+#RuntimeMaxUse=
+#RuntimeKeepFree=
+#RuntimeMaxFileSize=
+#RuntimeMinFileSize=