Including DStypes GaugeInc and GaugeAdd for tail plugin
authorAndre Ferraz <andre.ferraz@locaweb.com.br>
Thu, 24 Jul 2014 16:02:32 +0000 (13:02 -0300)
committerAndre Ferraz <andre.ferraz@locaweb.com.br>
Thu, 24 Jul 2014 16:02:32 +0000 (13:02 -0300)
src/tail.c
src/utils_match.c
src/utils_match.h

index 20f2a9b..b2d5226 100644 (file)
@@ -75,6 +75,10 @@ static int ctail_config_add_match_dstype (ctail_config_match_t *cm,
       cm->flags |= UTILS_MATCH_CF_GAUGE_MAX;
     else if (strcasecmp ("GaugeLast", ci->values[0].value.string) == 0)
       cm->flags |= UTILS_MATCH_CF_GAUGE_LAST;
+    else if (strcasecmp ("GaugeInc", ci->values[0].value.string) == 0)
+      cm->flags |= UTILS_MATCH_CF_GAUGE_INC;
+    else if (strcasecmp ("GaugeAdd", ci->values[0].value.string) == 0)
+      cm->flags |= UTILS_MATCH_CF_GAUGE_ADD;
     else
       cm->flags = 0;
   }
index 062bcfe..44eaece 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!");
index 36abe30..d32178a 100644 (file)
@@ -37,6 +37,8 @@
 #define UTILS_MATCH_CF_GAUGE_MIN     0x02
 #define UTILS_MATCH_CF_GAUGE_MAX     0x04
 #define UTILS_MATCH_CF_GAUGE_LAST    0x08
+#define UTILS_MATCH_CF_GAUGE_INC     0x09
+#define UTILS_MATCH_CF_GAUGE_ADD     0x10
 
 #define UTILS_MATCH_CF_COUNTER_SET   0x01
 #define UTILS_MATCH_CF_COUNTER_ADD   0x02