From: Florian Forster Date: Wed, 1 Jul 2009 14:55:38 +0000 (+0200) Subject: csv plugin: Improve handling of DERIVE and ABSOLUTE data source types. X-Git-Tag: collectd-4.8.0~91 X-Git-Url: https://git.verplant.org/?a=commitdiff_plain;h=0d10024adfd2f9a221da008c392f026264f8572a;p=collectd.git csv plugin: Improve handling of DERIVE and ABSOLUTE data source types. --- diff --git a/src/csv.c b/src/csv.c index f38599dc..78037a94 100644 --- a/src/csv.c +++ b/src/csv.c @@ -66,82 +66,45 @@ static int value_list_to_string (char *buffer, int buffer_len, && (ds->ds[i].type != DS_TYPE_ABSOLUTE)) return (-1); - if (ds->ds[i].type == DS_TYPE_COUNTER) - { - if (store_rates == 0) - { - status = ssnprintf (buffer + offset, - buffer_len - offset, - ",%llu", - vl->values[i].counter); - } - else /* if (store_rates == 1) */ - { - 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]); - } - } - else if (ds->ds[i].type == DS_TYPE_GAUGE) + 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_DERIVE) + else if (store_rates != 0) { - if (store_rates == 0) + if (rates == NULL) + rates = uc_get_rate (ds, vl); + if (rates == NULL) { - status = ssnprintf (buffer + offset, - buffer_len - offset, - ",%llu", - vl->values[i].derive); - } - else /* if (store_rates == 1) */ - { - 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]); + WARNING ("csv plugin: " + "uc_get_rate failed."); + return (-1); } + status = ssnprintf (buffer + offset, + buffer_len - offset, + ",%lf", rates[i]); + } + else if (ds->ds[i].type == DS_TYPE_COUNTER) + { + status = ssnprintf (buffer + offset, + buffer_len - offset, + ",%llu", + vl->values[i].counter); + } + else if (ds->ds[i].type == DS_TYPE_DERIVE) + { + status = ssnprintf (buffer + offset, + buffer_len - offset, + ",%"PRIi64, + vl->values[i].derive); } else if (ds->ds[i].type == DS_TYPE_ABSOLUTE) { - if (store_rates == 0) - { - status = ssnprintf (buffer + offset, - buffer_len - offset, - ",%llu", - vl->values[i].absolute); - } - else /* if (store_rates == 1) */ - { - 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]); - } + status = ssnprintf (buffer + offset, + buffer_len - offset, + ",%"PRIu64, + vl->values[i].absolute); } if ((status < 1) || (status >= (buffer_len - offset)))