summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: a49ed2a)
raw | patch | inline | side by side (parent: a49ed2a)
author | Florian Forster <octo@collectd.org> | |
Mon, 13 Feb 2012 13:33:44 +0000 (14:33 +0100) | ||
committer | Florian Forster <octo@collectd.org> | |
Mon, 13 Feb 2012 13:33:44 +0000 (14:33 +0100) |
There is no need for special handling of values with one / more data sources.
Change-Id: I849d4a881ed50ad1c7b8cf5c0abd1c5d62fe5258
Change-Id: I849d4a881ed50ad1c7b8cf5c0abd1c5d62fe5258
src/write_graphite.c | patch | blob | history |
diff --git a/src/write_graphite.c b/src/write_graphite.c
index b7924ba8c2d0166bfa8ead827f544eefd2005929..fc2e2edde5ad334859b025e02e567da8b1131207 100644 (file)
--- a/src/write_graphite.c
+++ b/src/write_graphite.c
return (-1);
}
-
pthread_mutex_lock (&cb->send_lock);
if (cb->sock_fd < 0)
return (status);
}
}
+
+ /* Assert that we have enough space for this message. */
assert (message_len < cb->send_buf_free);
/* `message_len + 1' because `message_len' does not include the
100.0 * ((double) cb->send_buf_fill) / ((double) sizeof (cb->send_buf)),
message);
- /* Check if we have enough space for this message. */
pthread_mutex_unlock (&cb->send_lock);
return (0);
return -1;
}
- if (ds->ds_num > 1)
- {
- for (i = 0; i < ds->ds_num; i++)
- {
- /* Copy the identifier to `key' and escape it. */
- status = wg_format_name (key, sizeof (key), vl, cb, ds->ds[i].name);
- if (status != 0)
- {
- ERROR ("write_graphite plugin: error with format_name");
- return (status);
- }
-
- 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,
- cb->store_rates);
- if (status != 0)
- {
- ERROR ("write_graphite plugin: error with "
- "wg_format_values");
- return (status);
- }
-
- /* Send the message to graphite */
- status = wg_send_message (key, values, vl->time, cb);
- if (status != 0)
- {
- ERROR ("write_graphite plugin: error with "
- "wg_send_message");
- return (status);
- }
- }
- }
- else
+ for (i = 0; i < ds->ds_num; i++)
{
+ const char *ds_name = NULL;
+
+ if (cb->always_append_ds || (ds->ds_num > 1))
+ ds_name = ds->ds[i].name;
+
/* Copy the identifier to `key' and escape it. */
- status = wg_format_name (key, sizeof (key), vl, cb,
- cb->always_append_ds ? ds->ds[0].name : NULL);
+ status = wg_format_name (key, sizeof (key), vl, cb, ds_name);
if (status != 0)
{
ERROR ("write_graphite plugin: error with format_name");
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,
+ status = wg_format_values (values, sizeof (values), i, ds, vl,
cb->store_rates);
if (status != 0)
{