@@ -241,31 +241,31 @@ static void pluginsd_main_cleanup(void *pptr) {
241241 worker_unregister ();
242242}
243243
244- static bool is_plugin (char * dst , size_t dst_size , const char * filename ) {
245244#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+ };
253252#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+ };
260259#endif
261260
261+ static bool is_plugin (char * dst , size_t dst_size , const char * filename ) {
262262 size_t filename_len = strlen (filename );
263263
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 ]);
266266
267267 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 ) {
269269 snprintfz (dst , dst_size , "%.*s" , (int )(filename_len - suffix_len ), filename );
270270 return true;
271271 }
@@ -274,6 +274,20 @@ static bool is_plugin(char *dst, size_t dst_size, const char *filename) {
274274 return false;
275275}
276276
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+
277291void * pluginsd_main (void * ptr ) {
278292 CLEANUP_FUNCTION_REGISTER (pluginsd_main_cleanup ) cleanup_ptr = ptr ;
279293
@@ -294,6 +308,8 @@ void *pluginsd_main(void *ptr) {
294308 // so that we don't log broken directories on each loop
295309 int directory_errors [PLUGINSD_MAX_DIRECTORIES ] = { 0 };
296310
311+ bool journal_viewer_exists = plugin_exists ("journal-viewer" );
312+
297313 while (service_running (SERVICE_COLLECTORS )) {
298314 int idx ;
299315 const char * directory_name ;
@@ -329,8 +345,12 @@ void *pluginsd_main(void *ptr) {
329345 }
330346
331347 // 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+ }
334354 continue ;
335355 }
336356
0 commit comments