amqp, write_graphite and write_kafka plugins: Implement the "[Graphite]PreserveSepara...
[collectd.git] / src / tail.c
index 732607c..0ac8be7 100644 (file)
@@ -85,6 +85,8 @@ static int ctail_config_add_match_dstype (ctail_config_match_t *cm,
       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 if (strcasecmp ("GaugePersist", ci->values[0].value.string) == 0)
+      cm->flags |= UTILS_MATCH_CF_GAUGE_PERSIST;
     else
       cm->flags = 0;
   }
@@ -140,7 +142,6 @@ static int ctail_config_add_match (cu_tail_match_t *tm,
 {
   ctail_config_match_t cm = { 0 };
   int status;
-  int i;
 
   if (ci->values_num != 0)
   {
@@ -148,7 +149,7 @@ static int ctail_config_add_match (cu_tail_match_t *tm,
   }
 
   status = 0;
-  for (i = 0; i < ci->children_num; i++)
+  for (int i = 0; i < ci->children_num; i++)
   {
     oconfig_item_t *option = ci->children + i;
 
@@ -223,7 +224,6 @@ static int ctail_config_add_file (oconfig_item_t *ci)
   cdtime_t interval = 0;
   char *plugin_instance = NULL;
   int num_matches = 0;
-  int i;
 
   if ((ci->values_num != 1) || (ci->values[0].type != OCONFIG_TYPE_STRING))
   {
@@ -239,7 +239,7 @@ static int ctail_config_add_file (oconfig_item_t *ci)
     return (-1);
   }
 
-  for (i = 0; i < ci->children_num; i++)
+  for (int i = 0; i < ci->children_num; i++)
   {
     oconfig_item_t *option = ci->children + i;
     int status = 0;
@@ -298,9 +298,7 @@ static int ctail_config_add_file (oconfig_item_t *ci)
 
 static int ctail_config (oconfig_item_t *ci)
 {
-  int i;
-
-  for (i = 0; i < ci->children_num; i++)
+  for (int i = 0; i < ci->children_num; i++)
   {
     oconfig_item_t *option = ci->children + i;
 
@@ -332,8 +330,6 @@ static int ctail_read (user_data_t *ud)
 static int ctail_init (void)
 {
   char str[255];
-  user_data_t ud = { 0 };
-  size_t i;
 
   if (tail_match_list_num == 0)
   {
@@ -341,11 +337,14 @@ static int ctail_init (void)
     return (-1);
   }
 
-  for (i = 0; i < tail_match_list_num; i++)
+  for (size_t i = 0; i < tail_match_list_num; i++)
   {
-    ud.data = (void *)tail_match_list[i];
     ssnprintf(str, sizeof(str), "tail-%zu", i);
-    plugin_register_complex_read (NULL, str, ctail_read, tail_match_list_intervals[i], &ud);
+
+    plugin_register_complex_read (NULL, str, ctail_read, tail_match_list_intervals[i],
+        &(user_data_t) {
+          .data = tail_match_list[i],
+        });
   }
 
   return (0);
@@ -353,9 +352,7 @@ static int ctail_init (void)
 
 static int ctail_shutdown (void)
 {
-  size_t i;
-
-  for (i = 0; i < tail_match_list_num; i++)
+  for (size_t i = 0; i < tail_match_list_num; i++)
   {
     tail_match_destroy (tail_match_list[i]);
     tail_match_list[i] = NULL;