processes plugin: ps_list_match: If a regex is configures, only use that regex.
[collectd.git] / src / plugin.c
index a4f96f8..8844c33 100644 (file)
@@ -21,6 +21,7 @@
  **/
 
 #include "collectd.h"
+#include "utils_complain.h"
 
 #include <ltdl.h>
 
@@ -441,7 +442,8 @@ int plugin_register_write (const char *name,
        return (register_callback (&list_write, name, (void *) callback));
 } /* int plugin_register_write */
 
-int plugin_register_flush (const char *name, int (*callback) (const int))
+int plugin_register_flush (const char *name,
+               int (*callback) (const int timeout, const char *identifier))
 {
        return (register_callback (&list_flush, name, (void *) callback));
 } /* int plugin_register_flush */
@@ -694,6 +696,28 @@ void plugin_flush_all (int timeout)
        }
 } /* void plugin_flush_all */
 
+int plugin_flush (const char *plugin, int timeout, const char *identifier)
+{
+  int (*callback) (int timeout, const char *identifier);
+  llentry_t *le;
+
+  if (list_flush == NULL)
+    return (0);
+
+  le = llist_head (list_flush);
+  while (le != NULL)
+  {
+    if ((plugin != NULL)
+       && (strcmp (plugin, le->key) != 0))
+      continue;
+
+    callback = (int (*) (int, const char *)) le->value;
+    le = le->next;
+
+    (*callback) (timeout, identifier);
+  }
+} /* int plugin_flush */
+
 void plugin_shutdown_all (void)
 {
        int (*callback) (void);
@@ -721,6 +745,8 @@ void plugin_shutdown_all (void)
 
 int plugin_dispatch_values (value_list_t *vl)
 {
+       static c_complain_t no_write_complaint = C_COMPLAIN_INIT;
+
        int (*callback) (const data_set_t *, const value_list_t *);
        data_set_t *ds;
        llentry_t *le;
@@ -731,12 +757,10 @@ int plugin_dispatch_values (value_list_t *vl)
        }
 
        if (list_write == NULL)
-       {
-               ERROR ("plugin_dispatch_values: No write callback has been "
-                               "registered. Please load at least one plugin "
-                               "that provides a write function.");
-               return (-1);
-       }
+               c_complain_once (LOG_WARNING, &no_write_complaint,
+                               "plugin_dispatch_values: No write callback has been "
+                               "registered. Please load at least one output plugin, "
+                               "if you want the collected data to be stored.");
 
        if (data_sets == NULL)
        {
@@ -765,7 +789,7 @@ int plugin_dispatch_values (value_list_t *vl)
        assert (0 == strcmp (ds->type, vl->type));
 #else
        if (0 != strcmp (ds->type, vl->type))
-               WARN ("plugin_dispatch_values: (ds->type = %s) != (vl->type = %s)",
+               WARNING ("plugin_dispatch_values: (ds->type = %s) != (vl->type = %s)",
                                ds->type, vl->type);
 #endif