workaround for systems that do not have SD_JOURNAL_OS_ROOT (#15837)
Costa Tsaousis committed
Aug 17, 2023 at 23:46 UTC
165aafbb56b7ce547f4254367e21a50f74af0aed
2 files changed
+19
collectors/systemd-journal.plugin/systemd-journal.c
+6
@@ -66,8 +66,14 @@ int systemd_journal_query(BUFFER *wb, FACETS *facets, usec_t after_ut, usec_t be
66
int r;
67
68
if(*netdata_configured_host_prefix) {
69
+#ifdef HAVE_SD_JOURNAL_OS_ROOT
70
// Give our host prefix to systemd journal
71
r = sd_journal_open_directory(&j, netdata_configured_host_prefix, SD_JOURNAL_OS_ROOT);
72
+#else
73
+ char buf[FILENAME_MAX + 1];
74
+ snprintfz(buf, FILENAME_MAX, "%s/var/log/journal", netdata_configured_host_prefix);
75
+ r = sd_journal_open_directory(&j, buf, 0);
76
+#endif
77
}
78
else {
79
// Open the system journal for reading
configure.ac
+13
@@ -1143,6 +1143,19 @@ AM_CONDITIONAL([ENABLE_PLUGIN_SYSTEMD_JOURNAL], [test "${enable_plugin_systemd_j
1143
1144
AC_MSG_NOTICE([OPTIONAL_SYSTEMD_LIBS is set to: ${OPTIONAL_SYSTEMD_LIBS}])
1145
1146
+if test "${enable_plugin_systemd_journal}" = "yes"; then
1147
+ AC_MSG_CHECKING([for SD_JOURNAL_OS_ROOT in systemd])
1148
+ AC_COMPILE_IFELSE(
1149
+ [AC_LANG_PROGRAM(
1150
+ [[#include <systemd/sd-journal.h>]],
1151
+ [[int x = SD_JOURNAL_OS_ROOT;]]
1152
+ )],
1153
+ [AC_DEFINE(HAVE_SD_JOURNAL_OS_ROOT, 1, [Define if SD_JOURNAL_OS_ROOT is available])
1154
+ AC_MSG_RESULT(yes)],
1155
+ [AC_MSG_RESULT(no)]
1156
+ )
1157
+fi
1158
+
1159
LIBS="${LIBS_BAK}"
1160
1161
# -----------------------------------------------------------------------------