diff options
author | Costa Tsaousis <costa@netdata.cloud> | 2023-08-17 23:46:52 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-08-17 23:46:52 +0300 |
commit | 165aafbb56b7ce547f4254367e21a50f74af0aed (patch) | |
tree | f0ed6674302b0b8bb444dfb4bd20c22c51076199 | |
parent | 45c016c8b890b0dcb65a09be955cd5b4a82934e1 (diff) |
workaround for systems that do not have SD_JOURNAL_OS_ROOT (#15837)
-rw-r--r-- | collectors/systemd-journal.plugin/systemd-journal.c | 6 | ||||
-rw-r--r-- | configure.ac | 13 |
2 files changed, 19 insertions, 0 deletions
diff --git a/collectors/systemd-journal.plugin/systemd-journal.c b/collectors/systemd-journal.plugin/systemd-journal.c index debe7906bb..1b7357099f 100644 --- a/collectors/systemd-journal.plugin/systemd-journal.c +++ b/collectors/systemd-journal.plugin/systemd-journal.c @@ -66,8 +66,14 @@ int systemd_journal_query(BUFFER *wb, FACETS *facets, usec_t after_ut, usec_t be int r; if(*netdata_configured_host_prefix) { +#ifdef HAVE_SD_JOURNAL_OS_ROOT // Give our host prefix to systemd journal r = sd_journal_open_directory(&j, netdata_configured_host_prefix, SD_JOURNAL_OS_ROOT); +#else + char buf[FILENAME_MAX + 1]; + snprintfz(buf, FILENAME_MAX, "%s/var/log/journal", netdata_configured_host_prefix); + r = sd_journal_open_directory(&j, buf, 0); +#endif } else { // Open the system journal for reading diff --git a/configure.ac b/configure.ac index c3ee7484a8..4e83efccdd 100644 --- a/configure.ac +++ b/configure.ac @@ -1143,6 +1143,19 @@ AM_CONDITIONAL([ENABLE_PLUGIN_SYSTEMD_JOURNAL], [test "${enable_plugin_systemd_j AC_MSG_NOTICE([OPTIONAL_SYSTEMD_LIBS is set to: ${OPTIONAL_SYSTEMD_LIBS}]) +if test "${enable_plugin_systemd_journal}" = "yes"; then + AC_MSG_CHECKING([for SD_JOURNAL_OS_ROOT in systemd]) + AC_COMPILE_IFELSE( + [AC_LANG_PROGRAM( + [[#include <systemd/sd-journal.h>]], + [[int x = SD_JOURNAL_OS_ROOT;]] + )], + [AC_DEFINE(HAVE_SD_JOURNAL_OS_ROOT, 1, [Define if SD_JOURNAL_OS_ROOT is available]) + AC_MSG_RESULT(yes)], + [AC_MSG_RESULT(no)] + ) +fi + LIBS="${LIBS_BAK}" # ----------------------------------------------------------------------------- |