summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: da112d8)
raw | patch | inline | side by side (parent: da112d8)
author | Florian Forster <octo@leeloo.lan.home.verplant.org> | |
Fri, 21 Aug 2009 08:22:59 +0000 (10:22 +0200) | ||
committer | Florian Forster <octo@leeloo.lan.home.verplant.org> | |
Fri, 21 Aug 2009 08:22:59 +0000 (10:22 +0200) |
src/http.c | patch | blob | history |
diff --git a/src/http.c b/src/http.c
index d6f7fee36c0389778089aa95e6155a1d7f568171..60535ba87f175871fdda7b49f74db0b2111b6c4d 100644 (file)
--- a/src/http.c
+++ b/src/http.c
int offset = 0;
int status;
int i;
- gauge_t *rates = NULL;
assert (0 == strcmp (ds->type, vl->type));
&& (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)
{
":%"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 */