Code

fix dstype gauge values and expands the number of possible subtypes
[collectd.git] / src / utils_match.c
index 4d4b57d08051b31e91dceb0a8bf43a4e67695dfe..44eaece201f6234a57bb3c449927c9c6b46ecf32 100644 (file)
@@ -80,6 +80,13 @@ static int default_callback (const char __attribute__((unused)) *str,
     gauge_t value;
     char *endptr = NULL;
 
+    if (data->ds_type & UTILS_MATCH_CF_GAUGE_INC)
+    {
+      data->value.gauge = isnan (data->value.gauge) ? 1 : data->value.gauge + 1;
+      data->values_num++;
+      return(0);
+    }
+
     if (matches_num < 2)
       return (-1);
 
@@ -108,6 +115,10 @@ static int default_callback (const char __attribute__((unused)) *str,
       if (data->value.gauge < value)
        data->value.gauge = value;
     }
+    else if (data->ds_type & UTILS_MATCH_CF_GAUGE_ADD)
+    {
+      data->value.gauge += value;
+    }
     else
     {
       ERROR ("utils_match: default_callback: obj->ds_type is invalid!");
@@ -228,7 +239,7 @@ cu_match_t *match_create_callback (const char *regex, const char *excluderegex,
     return (NULL);
   memset (obj, '\0', sizeof (cu_match_t));
 
-  status = regcomp (&obj->regex, regex, REG_EXTENDED);
+  status = regcomp (&obj->regex, regex, REG_EXTENDED | REG_NEWLINE);
   if (status != 0)
   {
     ERROR ("Compiling the regular expression \"%s\" failed.", regex);