Code

write_graphite plugin: Implement the StoreRates option.
authorFlorian Forster <octo@collectd.org>
Tue, 7 Feb 2012 16:59:00 +0000 (17:59 +0100)
committerFlorian Forster <octo@collectd.org>
Tue, 7 Feb 2012 16:59:00 +0000 (17:59 +0100)
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
src/write_graphite.c

index be2e8027085279eed1c746587854a28228d013b1..64ef7f2e9e49db053737dee5da9764bc1270797c 100644 (file)
@@ -4798,6 +4798,12 @@ in the identifier. The B<EscapeCharacter> option determines which character
 dots, whitespace and control characters are replaced with. Defaults to
 underscore (C<_>).
 
+=item B<StoreRates> B<false>|B<true>
+
+If set to B<true>, convert counter values to rates. If set to B<false> (the
+default) counter values are stored as is, i.E<nbsp>e. as an increasing integer
+number.
+
 =back
 
 =head2 Plugin C<write_http>
index f7ed1959e0b2dd471f892e1bed25dc97271e846e..cc4e38a3a7d69a695028e95a1f70c0afcd658bf3 100644 (file)
@@ -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