From c88393da956d25825a6cf287855b2ea871ffd781 Mon Sep 17 00:00:00 2001 From: Brian Kelly Date: Thu, 30 Jul 2015 09:42:36 -0400 Subject: [PATCH] write_redis plugin: Add support for StoreRates option --- src/collectd.conf.pod | 7 +++++++ src/write_redis.c | 7 ++++++- 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/src/collectd.conf.pod b/src/collectd.conf.pod index a06abe92..8a508089 100644 --- a/src/collectd.conf.pod +++ b/src/collectd.conf.pod @@ -7624,6 +7624,8 @@ Synopsis: Timeout 1000 Prefix "collectd/" Database 1 + MaxSetSize -1 + StoreRates true @@ -7685,6 +7687,11 @@ to C<0>. The B option limits the number of items that the I can hold. Negative values for I sets no limit, which is the default behavior. +=item B B|B + +If set to B (the default), convert counter values to rates. If set to +B counter values are stored as is, i.e. as an increasing integer number. + =back =head2 Plugin C diff --git a/src/write_redis.c b/src/write_redis.c index fe8994d5..1eb082fb 100644 --- a/src/write_redis.c +++ b/src/write_redis.c @@ -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); -- 2.30.2