Allow systemd-journal plugin if journal-viewer does not exist. (#21561)
vkalintiris committed
Jan 14, 2026 at 23:27 UTC
2b180ba017d777a9c9fbfc0c092b621ddde186f4
1 file changed
+39
-19
src/plugins.d/plugins_d.c
+39
-19
@@ -241,31 +241,31 @@ static void pluginsd_main_cleanup(void *pptr) {
241
worker_unregister();
242
}
243
244
-static bool is_plugin(char *dst, size_t dst_size, const char *filename) {
244
#if defined(OS_WINDOWS)
246
- const char *suffixes[] = {
247
- ".plugin.exe",
248
- "_plugin.exe",
249
- "-plugin.exe",
250
- ".plugin",
251
- NULL
252
- };
245
+static const char *plugin_suffixes[] = {
246
+ ".plugin.exe",
247
+ "_plugin.exe",
248
+ "-plugin.exe",
249
+ ".plugin",
250
+ NULL
251
+};
252
#else
254
- const char *suffixes[] = {
255
- ".plugin",
256
- "_plugin",
257
- "-plugin",
258
- NULL
259
- };
253
+static const char *plugin_suffixes[] = {
254
+ ".plugin",
255
+ "_plugin",
256
+ "-plugin",
257
+ NULL
258
+};
259
#endif
260
261
+static bool is_plugin(char *dst, size_t dst_size, const char *filename) {
262
size_t filename_len = strlen(filename);
263
264
- for (int i = 0; suffixes[i] != NULL; i++) {
265
- size_t suffix_len = strlen(suffixes[i]);
264
+ for (int i = 0; plugin_suffixes[i] != NULL; i++) {
265
+ size_t suffix_len = strlen(plugin_suffixes[i]);
266
267
if (filename_len > suffix_len &&
268
- strcmp(suffixes[i], &filename[filename_len - suffix_len]) == 0) {
268
+ strcmp(plugin_suffixes[i], &filename[filename_len - suffix_len]) == 0) {
269
snprintfz(dst, dst_size, "%.*s", (int)(filename_len - suffix_len), filename);
270
return true;
271
}
@@ -274,6 +274,20 @@ static bool is_plugin(char *dst, size_t dst_size, const char *filename) {
274
return false;
275
}
276
277
+static bool plugin_exists(const char *pluginname) {
278
+ char path[FILENAME_MAX + 1];
279
+
280
+ for (int idx = 0; idx < PLUGINSD_MAX_DIRECTORIES && plugin_directories[idx]; idx++) {
281
+ for (int i = 0; plugin_suffixes[i] != NULL; i++) {
282
+ snprintfz(path, sizeof(path), "%s/%s%s", plugin_directories[idx], pluginname, plugin_suffixes[i]);
283
+ if (access(path, F_OK) == 0)
284
+ return true;
285
+ }
286
+ }
287
+
288
+ return false;
289
+}
290
+
291
void *pluginsd_main(void *ptr) {
292
CLEANUP_FUNCTION_REGISTER(pluginsd_main_cleanup) cleanup_ptr = ptr;
293
@@ -294,6 +308,8 @@ void *pluginsd_main(void *ptr) {
308
// so that we don't log broken directories on each loop
309
int directory_errors[PLUGINSD_MAX_DIRECTORIES] = { 0 };
310
311
+ bool journal_viewer_exists = plugin_exists("journal-viewer");
312
+
313
while (service_running(SERVICE_COLLECTORS)) {
314
int idx;
315
const char *directory_name;
@@ -329,8 +345,12 @@ void *pluginsd_main(void *ptr) {
345
}
346
347
// Blacklist obsolete plugins that have been replaced
332
- if (strcmp(pluginname, "systemd-journal") == 0) {
333
- netdata_log_info("plugin '%s' has been replaced by 'journal-viewer' and is no longer supported", file->d_name);
348
+ if (strcmp(pluginname, "systemd-journal") == 0 && journal_viewer_exists) {
349
+ static bool logged = false;
350
+ if (!logged) {
351
+ netdata_log_info("plugin '%s' has been replaced by 'journal-viewer' and is no longer supported", file->d_name);
352
+ logged = true;
353
+ }
354
continue;
355
}
356