Merge branch 'collectd-4.5'
[collectd.git] / src / plugin.c
index f222e3a..4ad7366 100644 (file)
@@ -36,6 +36,7 @@
 #include "utils_llist.h"
 #include "utils_cache.h"
 #include "utils_threshold.h"
+#include "filter_chain.h"
 
 /*
  * Private structures
@@ -800,9 +801,6 @@ int plugin_dispatch_values (value_list_t *vl)
        static c_complain_t no_write_complaint = C_COMPLAIN_INIT_STATIC;
 
        data_set_t *ds;
-       llentry_t *le;
-
-       int filter = 0;
 
        if ((vl == NULL) || (*vl->type == '\0')) {
                ERROR ("plugin_dispatch_values: Invalid value list.");
@@ -865,39 +863,10 @@ int plugin_dispatch_values (value_list_t *vl)
        escape_slashes (vl->type, sizeof (vl->type));
        escape_slashes (vl->type_instance, sizeof (vl->type_instance));
 
-       le = llist_head (list_filter);
-       while (le != NULL)
-       {
-               int (*filter_callback) (const data_set_t *, value_list_t *) =
-                               (int (*) (const data_set_t *, value_list_t *)) le->value;
-
-               filter |= (*filter_callback) (ds, vl);
-
-               if (filter == FILTER_IGNORE)
-                       return (-1);
-
-               le = le->next;
-       }
-
        /* Update the value cache */
        uc_update (ds, vl);
 
-       if ((filter & FILTER_NOTHRESHOLD_CHECK) == 0)
-               ut_check_threshold (ds, vl);
-
-       if (filter & FILTER_NOWRITE)
-               return (0);
-
-       le = llist_head (list_write);
-       while (le != NULL)
-       {
-               int (*write_callback) (const data_set_t *, const value_list_t *) =
-                               (int (*) (const data_set_t *, const value_list_t *)) le->value;
-
-               (*write_callback) (ds, vl);
-
-               le = le->next;
-       }
+       fc_process (ds, vl);
 
        return (0);
 } /* int plugin_dispatch_values */
@@ -1002,8 +971,8 @@ static int plugin_notification_meta_add (notification_t *n,
   {
     case NM_TYPE_STRING:
     {
-      meta->value_string = strdup ((const char *) value);
-      if (meta->value_string == NULL)
+      meta->nm_value.nm_string = strdup ((const char *) value);
+      if (meta->nm_value.nm_string == NULL)
       {
         ERROR ("plugin_notification_meta_add: strdup failed.");
         sfree (meta);
@@ -1013,22 +982,22 @@ static int plugin_notification_meta_add (notification_t *n,
     }
     case NM_TYPE_SIGNED_INT:
     {
-      meta->value_signed_int = *((int64_t *) value);
+      meta->nm_value.nm_signed_int = *((int64_t *) value);
       break;
     }
     case NM_TYPE_UNSIGNED_INT:
     {
-      meta->value_unsigned_int = *((uint64_t *) value);
+      meta->nm_value.nm_unsigned_int = *((uint64_t *) value);
       break;
     }
     case NM_TYPE_DOUBLE:
     {
-      meta->value_double = *((double *) value);
+      meta->nm_value.nm_double = *((double *) value);
       break;
     }
     case NM_TYPE_BOOLEAN:
     {
-      meta->value_boolean = *((bool *) value);
+      meta->nm_value.nm_boolean = *((bool *) value);
       break;
     }
     default:
@@ -1101,19 +1070,19 @@ int plugin_notification_meta_copy (notification_t *dst,
   {
     if (meta->type == NM_TYPE_STRING)
       plugin_notification_meta_add_string (dst, meta->name,
-          meta->value_string);
+          meta->nm_value.nm_string);
     else if (meta->type == NM_TYPE_SIGNED_INT)
       plugin_notification_meta_add_signed_int (dst, meta->name,
-          meta->value_signed_int);
+          meta->nm_value.nm_signed_int);
     else if (meta->type == NM_TYPE_UNSIGNED_INT)
       plugin_notification_meta_add_unsigned_int (dst, meta->name,
-          meta->value_unsigned_int);
+          meta->nm_value.nm_unsigned_int);
     else if (meta->type == NM_TYPE_DOUBLE)
       plugin_notification_meta_add_double (dst, meta->name,
-          meta->value_double);
+          meta->nm_value.nm_double);
     else if (meta->type == NM_TYPE_BOOLEAN)
       plugin_notification_meta_add_boolean (dst, meta->name,
-          meta->value_boolean);
+          meta->nm_value.nm_boolean);
   }
 
   return (0);
@@ -1138,8 +1107,8 @@ int plugin_notification_meta_free (notification_t *n)
 
     if (this->type == NM_TYPE_STRING)
     {
-      free ((char *)this->value_string);
-      this->value_string = NULL;
+      free ((char *)this->nm_value.nm_string);
+      this->nm_value.nm_string = NULL;
     }
     sfree (this);