From 3e9d0babd83c359ffa114c0bc0f808cade99e3e8 Mon Sep 17 00:00:00 2001 From: Florian Forster Date: Tue, 7 Feb 2012 17:59:00 +0100 Subject: [PATCH] write_graphite plugin: Implement the StoreRates option. Most of it was already present in the code anyway, so I just added the appropriate config handling. Change-Id: I7ce8be2f5b075da690872ec72b3610eae05b3c6c --- src/collectd.conf.pod | 6 ++++++ src/write_graphite.c | 10 ++++++++-- 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/src/collectd.conf.pod b/src/collectd.conf.pod index be2e8027..64ef7f2e 100644 --- a/src/collectd.conf.pod +++ b/src/collectd.conf.pod @@ -4798,6 +4798,12 @@ in the identifier. The B option determines which character dots, whitespace and control characters are replaced with. Defaults to underscore (C<_>). +=item B B|B + +If set to B, convert counter values to rates. If set to B (the +default) counter values are stored as is, i.Ee. as an increasing integer +number. + =back =head2 Plugin C diff --git a/src/write_graphite.c b/src/write_graphite.c index f7ed1959..cc4e38a3 100644 --- a/src/write_graphite.c +++ b/src/write_graphite.c @@ -92,6 +92,8 @@ struct wg_callback char *postfix; char escape_char; + _Bool store_rates; + char send_buf[WG_SEND_BUF_SIZE]; size_t send_buf_free; size_t send_buf_fill; @@ -539,7 +541,8 @@ static int wg_write_messages (const data_set_t *ds, const value_list_t *vl, escape_string (key, sizeof (key)); /* Convert the values to an ASCII representation and put that * into `values'. */ - status = wg_format_values (values, sizeof (values), i, ds, vl, 0); + status = wg_format_values (values, sizeof (values), i, ds, vl, + cb->store_rates); if (status != 0) { ERROR ("write_graphite plugin: error with " @@ -570,7 +573,8 @@ static int wg_write_messages (const data_set_t *ds, const value_list_t *vl, escape_string (key, sizeof (key)); /* Convert the values to an ASCII representation and put that into * `values'. */ - status = wg_format_values (values, sizeof (values), 0, ds, vl, 0); + status = wg_format_values (values, sizeof (values), 0, ds, vl, + cb->store_rates); if (status != 0) { ERROR ("write_graphite plugin: error with " @@ -656,6 +660,8 @@ static int wg_config_carbon (oconfig_item_t *ci) cf_util_get_string (child, &cb->prefix); else if (strcasecmp ("Postfix", child->key) == 0) cf_util_get_string (child, &cb->postfix); + else if (strcasecmp ("StoreRates", child->key) == 0) + cf_util_get_boolean (child, &cb->store_rates); else if (strcasecmp ("EscapeCharacter", child->key) == 0) config_set_char (&cb->escape_char, child); else -- 2.11.0