Skip to content

Commit

Permalink
system: use keep-timestamp(no) in case of Linux kernel log messages
Browse files Browse the repository at this point in the history
Kernel messages read from /dev/kmsg may not have accurate timestamps.
The  time  source  used for the logs is not updated after system
 SUSPEND/RESUME. With this patch we ignore the original (and possibly
 inaccurate) timestamp and use the time of reception.

Fixes syslog-ng#121

Signed-off-by: Tibor Benke <tibor.benke@balabit.com>
  • Loading branch information
ihrwein authored and Tibor Benke committed Nov 9, 2015
1 parent 2932bef commit e435faa
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions modules/system-source/system-source.c
Expand Up @@ -76,7 +76,8 @@ system_sysblock_add_unix_dgram(GString *sysblock, const gchar *path,
static void
system_sysblock_add_file(GString *sysblock, const gchar *path,
gint follow_freq, const gchar *prg_override,
const gchar *flags, const gchar *format)
const gchar *flags, const gchar *format,
gboolean ignore_timestamp)
{
g_string_append_printf(sysblock, "file(\"%s\"", path);
if (follow_freq >= 0)
Expand All @@ -87,6 +88,8 @@ system_sysblock_add_file(GString *sysblock, const gchar *path,
g_string_append_printf(sysblock, " flags(%s)", flags);
if (format)
g_string_append_printf(sysblock, " format(%s)", format);
if (ignore_timestamp)
g_string_append_printf(sysblock, " keep-timestamp(no)");
g_string_append(sysblock, ");\n");
}

Expand Down Expand Up @@ -157,9 +160,9 @@ system_sysblock_add_freebsd_klog(GString *sysblock, const gchar *release)
if (strncmp(release, "7.", 2) == 0 ||
strncmp(release, "8.", 2) == 0 ||
strncmp(release, "9.0", 3) == 0)
system_sysblock_add_file(sysblock, "/dev/klog", 1, "kernel", "no-parse", NULL);
system_sysblock_add_file(sysblock, "/dev/klog", 1, "kernel", "no-parse", NULL, FALSE);
else
system_sysblock_add_file(sysblock, "/dev/klog", 0, "kernel", "no-parse", NULL);
system_sysblock_add_file(sysblock, "/dev/klog", 0, "kernel", "no-parse", NULL, FALSE);
}

static gboolean
Expand Down Expand Up @@ -212,7 +215,7 @@ system_sysblock_add_linux_kmsg(GString *sysblock)
}
else
system_sysblock_add_file(sysblock, kmsg, -1,
"kernel", "kernel", format);
"kernel", "kernel", format, TRUE);
}

static gboolean
Expand Down

0 comments on commit e435faa

Please sign in to comment.