From 9870ddc3e717d5a715092dabea12854f29353199 Mon Sep 17 00:00:00 2001 From: Florian Forster Date: Fri, 21 Aug 2009 10:22:59 +0200 Subject: [PATCH] http plugin: Don't convert COUNTER values to rates. --- src/http.c | 31 ++++++++----------------------- 1 file changed, 8 insertions(+), 23 deletions(-) diff --git a/src/http.c b/src/http.c index d6f7fee3..60535ba8 100644 --- a/src/http.c +++ b/src/http.c @@ -109,7 +109,6 @@ static int http_value_list_to_string (char *buffer, int buffer_len, /* {{{ */ int offset = 0; int status; int i; - gauge_t *rates = NULL; assert (0 == strcmp (ds->type, vl->type)); @@ -123,24 +122,21 @@ static int http_value_list_to_string (char *buffer, int buffer_len, /* {{{ */ && (ds->ds[i].type != DS_TYPE_ABSOLUTE)) return (-1); + status = -1; if (ds->ds[i].type == DS_TYPE_GAUGE) { status = ssnprintf (buffer + offset, buffer_len - offset, ":%lf", vl->values[i].gauge); } - else if (ds->ds[i].type == DS_TYPE_COUNTER) + else if ((ds->ds[i].type == DS_TYPE_COUNTER) + || (ds->ds[i].type == DS_TYPE_ABSOLUTE)) { - if (rates == NULL) - rates = uc_get_rate (ds, vl); - if (rates == NULL) - { - WARNING ("csv plugin: " - "uc_get_rate failed."); - return (-1); - } status = ssnprintf (buffer + offset, buffer_len - offset, - ":%lf", rates[i]); + ":%"PRIu64, + (ds->ds[i].type == DS_TYPE_COUNTER) + ? vl->values[i].counter + : vl->values[i].absolute); } else if (ds->ds[i].type == DS_TYPE_DERIVE) { @@ -149,24 +145,13 @@ static int http_value_list_to_string (char *buffer, int buffer_len, /* {{{ */ ":%"PRIi64, vl->values[i].derive); } - else if (ds->ds[i].type == DS_TYPE_ABSOLUTE) - { - status = ssnprintf (buffer + offset, - buffer_len - offset, - ":%"PRIu64, - vl->values[i].absolute); - } if ((status < 1) || (status >= (buffer_len - offset))) - { - sfree (rates); - return (-1); - } + return (-1); offset += status; } /* for ds->ds_num */ - sfree (rates); return (0); } /* }}} int http_value_list_to_string */ -- 2.30.2