summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 67e4e51)
raw | patch | inline | side by side (parent: 67e4e51)
author | Paul Sadauskas <psadauskas@gmail.com> | |
Mon, 15 Feb 2010 04:18:58 +0000 (21:18 -0700) | ||
committer | Sebastian Harl <sh@tokkee.org> | |
Thu, 25 Feb 2010 23:21:37 +0000 (00:21 +0100) |
Signed-off-by: Sebastian Harl <sh@tokkee.org>
src/collectd.conf.pod | patch | blob | history | |
src/write_http.c | patch | blob | history |
diff --git a/src/collectd.conf.pod b/src/collectd.conf.pod
index 3a6f9a28b55c0001ccd425e54f90013d24401bd7..09508f70add086d1360357363132b6f7eedf9203 100644 (file)
--- a/src/collectd.conf.pod
+++ b/src/collectd.conf.pod
Defaults to B<Command>.
+=item B<StoreRates> B<true|false>
+
+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
=head1 THRESHOLD CONFIGURATION
diff --git a/src/write_http.c b/src/write_http.c
index 1a490399ec30e18fd863740fb1094b4baa94100c..62e3cf3be067d0cb391ae798f734247cce621cc0 100644 (file)
--- a/src/write_http.c
+++ b/src/write_http.c
int verify_peer;
int verify_host;
char *cacert;
+ int store_rates;
#define WH_FORMAT_COMMAND 0
#define WH_FORMAT_JSON 1
static int wh_value_list_to_string (char *buffer, /* {{{ */
size_t buffer_size,
- const data_set_t *ds, const value_list_t *vl)
+ const data_set_t *ds, const value_list_t *vl,
+ wh_callback_t *cb)
{
size_t offset = 0;
int status;
int i;
+ gauge_t *rates = NULL;
assert (0 == strcmp (ds->type, vl->type));
if (ds->ds[i].type == DS_TYPE_GAUGE)
BUFFER_ADD (":%f", vl->values[i].gauge);
else if (ds->ds[i].type == DS_TYPE_COUNTER)
- BUFFER_ADD (":%llu", vl->values[i].counter);
+ {
+ if (cb->store_rates != 0)
+ {
+ if (rates == NULL)
+ rates = uc_get_rate (ds, vl);
+ if (rates == NULL)
+ {
+ WARNING ("write_http plugin: "
+ "uc_get_rate failed.");
+ return (-1);
+ }
+ BUFFER_ADD (":%lf", rates[i]);
+ }
+ else
+ BUFFER_ADD (":%llu", vl->values[i].counter);
+ }
else if (ds->ds[i].type == DS_TYPE_DERIVE)
BUFFER_ADD (":%"PRIi64, vl->values[i].derive);
else if (ds->ds[i].type == DS_TYPE_ABSOLUTE)
@@ -343,7 +361,7 @@ static int wh_write_command (const data_set_t *ds, const value_list_t *vl, /* {{
/* Convert the values to an ASCII representation and put that into
* `values'. */
- status = wh_value_list_to_string (values, sizeof (values), ds, vl);
+ status = wh_value_list_to_string (values, sizeof (values), ds, vl, cb);
if (status != 0) {
ERROR ("write_http plugin: error with "
"wh_value_list_to_string");
config_set_string (&cb->cacert, child);
else if (strcasecmp ("Format", child->key) == 0)
config_set_format (cb, child);
+ else if (strcasecmp ("StoreRates", child->key) == 0)
+ config_set_boolean (&cb->store_rates, child);
else
{
ERROR ("write_http plugin: Invalid configuration "