Code

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 20f2a9b47cdf380c4ff81100de2ae33cd3f72de6..b2d5226857714a8ed40f0c0836d506a4bcb17068 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 062bcfe37fd152851eb11eb03464daabe0b53ae2..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!");
index 36abe30ca427ee48861a792e0563cd327fa953b1..d32178a43800aff05c6236569f21acf11d88090a 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