write_redis plugin: Add support for StoreRates option
authorBrian Kelly <brianpkelly46@gmail.com>
Thu, 30 Jul 2015 13:42:36 +0000 (09:42 -0400)
committerMarc Fournier <marc.fournier@camptocamp.com>
Tue, 27 Oct 2015 23:31:01 +0000 (00:31 +0100)
src/collectd.conf.pod
src/write_redis.c

index a06abe9..8a50808 100644 (file)
@@ -7624,6 +7624,8 @@ Synopsis:
         Timeout 1000
         Prefix "collectd/"
         Database 1
+        MaxSetSize -1
+        StoreRates true
     </Node>
   </Plugin>
 
@@ -7685,6 +7687,11 @@ to C<0>.
 The B<MaxSetSize> option limits the number of items that the I<Sorted Sets> can
 hold. Negative values for I<Items> sets no limit, which is the default behavior.
 
+=item B<StoreRates> B<true>|B<false>
+
+If set to B<true> (the default), convert counter values to rates. If set to
+B<false> counter values are stored as is, i.e. as an increasing integer number.
+
 =back
 
 =head2 Plugin C<write_riemann>
index fe8994d..1eb082f 100644 (file)
@@ -47,6 +47,7 @@ struct wr_node_s
   char *prefix;
   int database;
   int max_set_size;
+  _Bool store_rates;
 
   redisContext *conn;
   pthread_mutex_t lock;
@@ -81,7 +82,7 @@ static int wr_write (const data_set_t *ds, /* {{{ */
   memset (value, 0, sizeof (value));
   value_size = sizeof (value);
   value_ptr = &value[0];
-  status = format_values (value_ptr, value_size, ds, vl, /* store rates = */ 0);
+  status = format_values (value_ptr, value_size, ds, vl, node->store_rates);
   pthread_mutex_lock (&node->lock);
   if (status != 0)
     return (status);
@@ -181,6 +182,7 @@ static int wr_config_node (oconfig_item_t *ci) /* {{{ */
   node->prefix = NULL;
   node->database = 0;
   node->max_set_size = -1;
+  node->store_rates = 1;
   pthread_mutex_init (&node->lock, /* attr = */ NULL);
 
   status = cf_util_get_string_buffer (ci, node->name, sizeof (node->name));
@@ -218,6 +220,9 @@ static int wr_config_node (oconfig_item_t *ci) /* {{{ */
     else if (strcasecmp ("MaxSetSize", child->key) == 0) {
       status = cf_util_get_int (child, &node->max_set_size);
     }
+    else if (strcasecmp ("StoreRates", child->key) == 0) {
+      status = cf_util_get_boolean (child, &node->store_rates);
+    }
     else
       WARNING ("write_redis plugin: Ignoring unknown config option \"%s\".",
           child->key);