From: Florian Forster Date: Tue, 7 Feb 2012 16:59:00 +0000 (+0100) Subject: write_graphite plugin: Implement the StoreRates option. X-Git-Tag: collectd-5.1.0~33^2~11 X-Git-Url: https://git.tokkee.org/?a=commitdiff_plain;h=3e9d0babd83c359ffa114c0bc0f808cade99e3e8;p=collectd.git 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 --- 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