systemd-journal: exit if unable to locate journal data directories (#16592)
Ilya Mashchenko committed
Dec 13, 2023 at 12:48 UTC
6fac4d3610ba7b4c520f834eeca1398033d42b5e
1 file changed
+16
collectors/systemd-journal.plugin/systemd-main.c
+16
@@ -8,6 +8,15 @@
8
netdata_mutex_t stdout_mutex = NETDATA_MUTEX_INITIALIZER;
9
static bool plugin_should_exit = false;
10
11
+static bool journal_data_direcories_exist() {
12
+ struct stat st;
13
+ for (unsigned i = 0; i < MAX_JOURNAL_DIRECTORIES && journal_directories[i].path; i++) {
14
+ if ((stat(journal_directories[i].path, &st) == 0) && S_ISDIR(st.st_mode))
15
+ return true;
16
+ }
17
+ return false;
18
+}
19
+
20
int main(int argc __maybe_unused, char **argv __maybe_unused) {
21
clocks_init();
22
netdata_thread_set_tag("SDMAIN");
@@ -23,6 +32,13 @@ int main(int argc __maybe_unused, char **argv __maybe_unused) {
32
journal_init_query_status();
33
journal_init_files_and_directories();
34
35
+ if (!journal_data_direcories_exist()) {
36
+ nd_log_collector(NDLP_INFO, "unable to locate journal data directories. Exiting...");
37
+ fprintf(stdout, "DISABLE\n");
38
+ fflush(stdout);
39
+ exit(0);
40
+ }
41
+
42
// ------------------------------------------------------------------------
43
// debug
44