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)
{