2 * collectd - src/write_riemann.c
3 * Copyright (C) 2012,2013 Pierre-Yves Ritschard
4 * Copyright (C) 2013 Florian octo Forster
5 * Copyright (C) 2015,2016 Gergely Nagy
7 * Permission is hereby granted, free of charge, to any person obtaining a
8 * copy of this software and associated documentation files (the "Software"),
9 * to deal in the Software without restriction, including without limitation
10 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
11 * and/or sell copies of the Software, and to permit persons to whom the
12 * Software is furnished to do so, subject to the following conditions:
14 * The above copyright notice and this permission notice shall be included in
15 * all copies or substantial portions of the Software.
17 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
20 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
21 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
22 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
23 * DEALINGS IN THE SOFTWARE.
26 * Pierre-Yves Ritschard <pyr at spootnik.org>
27 * Florian octo Forster <octo at collectd.org>
28 * Gergely Nagy <algernon at madhouse-project.org>
31 #include <riemann/riemann-client.h>
38 #include "configfile.h"
39 #include "utils_cache.h"
40 #include "utils_complain.h"
41 #include "write_riemann_threshold.h"
43 #define RIEMANN_HOST "localhost"
44 #define RIEMANN_PORT 5555
45 #define RIEMANN_TTL_FACTOR 2.0
46 #define RIEMANN_BATCH_MAX 8192
49 c_complain_t init_complaint;
51 char *event_service_prefix;
55 _Bool check_thresholds;
57 _Bool always_append_ds;
60 riemann_client_type_t client_type;
61 riemann_client_t *client;
67 riemann_message_t *batch_msg;
71 struct timeval timeout;
74 static char **riemann_tags;
75 static size_t riemann_tags_num;
76 static char **riemann_attrs;
77 static size_t riemann_attrs_num;
79 /* host->lock must be held when calling this function. */
80 static int wrr_connect(struct riemann_host *host) /* {{{ */
88 node = (host->node != NULL) ? host->node : RIEMANN_HOST;
89 port = (host->port) ? host->port : RIEMANN_PORT;
93 host->client = riemann_client_create(host->client_type, node, port,
94 RIEMANN_CLIENT_OPTION_TLS_CA_FILE, host->tls_ca_file,
95 RIEMANN_CLIENT_OPTION_TLS_CERT_FILE, host->tls_cert_file,
96 RIEMANN_CLIENT_OPTION_TLS_KEY_FILE, host->tls_key_file,
97 RIEMANN_CLIENT_OPTION_NONE);
98 if (host->client == NULL) {
99 c_complain (LOG_ERR, &host->init_complaint,
100 "write_riemann plugin: Unable to connect to Riemann at %s:%d",
104 if (host->timeout.tv_sec != 0) {
105 if (riemann_client_set_timeout(host->client, &host->timeout) != 0) {
106 riemann_client_free(host->client);
108 c_complain (LOG_ERR, &host->init_complaint,
109 "write_riemann plugin: Unable to connect to Riemann at %s:%d",
115 c_release (LOG_INFO, &host->init_complaint,
116 "write_riemann plugin: Successfully connected to %s:%d",
120 } /* }}} int wrr_connect */
122 /* host->lock must be held when calling this function. */
123 static int wrr_disconnect(struct riemann_host *host) /* {{{ */
128 riemann_client_free(host->client);
132 } /* }}} int wrr_disconnect */
135 * Function to send messages to riemann.
137 * Acquires the host lock, disconnects on errors.
139 static int wrr_send(struct riemann_host *host, riemann_message_t *msg) /* {{{ */
142 pthread_mutex_lock (&host->lock);
144 status = wrr_connect(host);
146 pthread_mutex_unlock(&host->lock);
150 status = riemann_client_send_message(host->client, msg);
152 wrr_disconnect(host);
153 pthread_mutex_unlock(&host->lock);
158 * For TCP we need to receive message acknowledgemenent.
160 if (host->client_type != RIEMANN_CLIENT_UDP)
162 riemann_message_t *response;
164 response = riemann_client_recv_message(host->client);
166 if (response == NULL)
168 wrr_disconnect(host);
169 pthread_mutex_unlock(&host->lock);
172 riemann_message_free(response);
175 pthread_mutex_unlock (&host->lock);
177 } /* }}} int wrr_send */
179 static riemann_message_t *wrr_notification_to_message(struct riemann_host *host, /* {{{ */
180 notification_t const *n)
182 riemann_message_t *msg;
183 riemann_event_t *event;
184 char service_buffer[6 * DATA_MAX_NAME_LEN];
185 char const *severity;
186 notification_meta_t *meta;
191 case NOTIF_OKAY: severity = "ok"; break;
192 case NOTIF_WARNING: severity = "warning"; break;
193 case NOTIF_FAILURE: severity = "critical"; break;
194 default: severity = "unknown";
197 format_name(service_buffer, sizeof(service_buffer),
198 /* host = */ "", n->plugin, n->plugin_instance,
199 n->type, n->type_instance);
201 event = riemann_event_create(RIEMANN_EVENT_FIELD_HOST, n->host,
202 RIEMANN_EVENT_FIELD_TIME, (int64_t) CDTIME_T_TO_TIME_T(n->time),
203 RIEMANN_EVENT_FIELD_TAGS, "notification", NULL,
204 RIEMANN_EVENT_FIELD_STATE, severity,
205 RIEMANN_EVENT_FIELD_SERVICE, &service_buffer[1],
206 RIEMANN_EVENT_FIELD_NONE);
209 riemann_event_string_attribute_add(event, "host", n->host);
210 if (n->plugin[0] != 0)
211 riemann_event_string_attribute_add(event, "plugin", n->plugin);
212 if (n->plugin_instance[0] != 0)
213 riemann_event_string_attribute_add(event, "plugin_instance", n->plugin_instance);
216 riemann_event_string_attribute_add(event, "type", n->type);
217 if (n->type_instance[0] != 0)
218 riemann_event_string_attribute_add(event, "type_instance", n->type_instance);
220 for (i = 0; i < riemann_attrs_num; i += 2)
221 riemann_event_string_attribute_add(event, riemann_attrs[i], riemann_attrs[i+1]);
223 for (i = 0; i < riemann_tags_num; i++)
224 riemann_event_tag_add(event, riemann_tags[i]);
226 if (n->message[0] != 0)
227 riemann_event_string_attribute_add(event, "description", n->message);
229 /* Pull in values from threshold and add extra attributes */
230 for (meta = n->meta; meta != NULL; meta = meta->next)
232 if (strcasecmp("CurrentValue", meta->name) == 0 && meta->type == NM_TYPE_DOUBLE)
234 riemann_event_set(event,
235 RIEMANN_EVENT_FIELD_METRIC_D,
236 (double) meta->nm_value.nm_double,
237 RIEMANN_EVENT_FIELD_NONE);
241 if (meta->type == NM_TYPE_STRING) {
242 riemann_event_string_attribute_add(event, meta->name, meta->nm_value.nm_string);
247 msg = riemann_message_create_with_events(event, NULL);
250 ERROR("write_riemann plugin: riemann_message_create_with_events() failed.");
251 riemann_event_free (event);
255 DEBUG("write_riemann plugin: Successfully created message for notification: "
256 "host = \"%s\", service = \"%s\", state = \"%s\"",
257 event->host, event->service, event->state);
259 } /* }}} riemann_message_t *wrr_notification_to_message */
261 static riemann_event_t *wrr_value_to_event(struct riemann_host const *host, /* {{{ */
262 data_set_t const *ds,
263 value_list_t const *vl, size_t index,
264 gauge_t const *rates,
267 riemann_event_t *event;
268 char name_buffer[5 * DATA_MAX_NAME_LEN];
269 char service_buffer[6 * DATA_MAX_NAME_LEN];
272 event = riemann_event_new();
275 ERROR("write_riemann plugin: riemann_event_new() failed.");
279 format_name(name_buffer, sizeof(name_buffer),
280 /* host = */ "", vl->plugin, vl->plugin_instance,
281 vl->type, vl->type_instance);
282 if (host->always_append_ds || (ds->ds_num > 1))
284 if (host->event_service_prefix == NULL)
285 ssnprintf(service_buffer, sizeof(service_buffer), "%s/%s",
286 &name_buffer[1], ds->ds[index].name);
288 ssnprintf(service_buffer, sizeof(service_buffer), "%s%s/%s",
289 host->event_service_prefix, &name_buffer[1], ds->ds[index].name);
293 if (host->event_service_prefix == NULL)
294 sstrncpy(service_buffer, &name_buffer[1], sizeof(service_buffer));
296 ssnprintf(service_buffer, sizeof(service_buffer), "%s%s",
297 host->event_service_prefix, &name_buffer[1]);
300 riemann_event_set(event,
301 RIEMANN_EVENT_FIELD_HOST, vl->host,
302 RIEMANN_EVENT_FIELD_TIME, (int64_t) CDTIME_T_TO_TIME_T(vl->time),
303 RIEMANN_EVENT_FIELD_TTL, (float) CDTIME_T_TO_DOUBLE(vl->interval) * host->ttl_factor,
304 RIEMANN_EVENT_FIELD_STRING_ATTRIBUTES,
305 "plugin", vl->plugin,
307 "ds_name", ds->ds[index].name,
309 RIEMANN_EVENT_FIELD_SERVICE, service_buffer,
310 RIEMANN_EVENT_FIELD_NONE);
312 if (host->check_thresholds) {
313 const char *state = NULL;
330 riemann_event_set(event, RIEMANN_EVENT_FIELD_STATE, state,
331 RIEMANN_EVENT_FIELD_NONE);
334 if (vl->plugin_instance[0] != 0)
335 riemann_event_string_attribute_add(event, "plugin_instance", vl->plugin_instance);
336 if (vl->type_instance[0] != 0)
337 riemann_event_string_attribute_add(event, "type_instance", vl->type_instance);
339 if ((ds->ds[index].type != DS_TYPE_GAUGE) && (rates != NULL))
341 char ds_type[DATA_MAX_NAME_LEN];
343 ssnprintf(ds_type, sizeof(ds_type), "%s:rate",
344 DS_TYPE_TO_STRING(ds->ds[index].type));
345 riemann_event_string_attribute_add(event, "ds_type", ds_type);
349 riemann_event_string_attribute_add(event, "ds_type",
350 DS_TYPE_TO_STRING(ds->ds[index].type));
354 char ds_index[DATA_MAX_NAME_LEN];
356 ssnprintf(ds_index, sizeof(ds_index), "%zu", index);
357 riemann_event_string_attribute_add(event, "ds_index", ds_index);
360 for (i = 0; i < riemann_attrs_num; i += 2)
361 riemann_event_string_attribute_add(event, riemann_attrs[i], riemann_attrs[i +1]);
363 for (i = 0; i < riemann_tags_num; i++)
364 riemann_event_tag_add(event, riemann_tags[i]);
366 if (ds->ds[index].type == DS_TYPE_GAUGE)
368 riemann_event_set(event,
369 RIEMANN_EVENT_FIELD_METRIC_D,
370 (double) vl->values[index].gauge,
371 RIEMANN_EVENT_FIELD_NONE);
373 else if (rates != NULL)
375 riemann_event_set(event,
376 RIEMANN_EVENT_FIELD_METRIC_D,
377 (double) rates[index],
378 RIEMANN_EVENT_FIELD_NONE);
384 if (ds->ds[index].type == DS_TYPE_DERIVE)
385 metric = (int64_t) vl->values[index].derive;
386 else if (ds->ds[index].type == DS_TYPE_ABSOLUTE)
387 metric = (int64_t) vl->values[index].absolute;
389 metric = (int64_t) vl->values[index].counter;
391 riemann_event_set(event,
392 RIEMANN_EVENT_FIELD_METRIC_S64,
394 RIEMANN_EVENT_FIELD_NONE);
397 DEBUG("write_riemann plugin: Successfully created message for metric: "
398 "host = \"%s\", service = \"%s\"",
399 event->host, event->service);
401 } /* }}} riemann_event_t *wrr_value_to_event */
403 static riemann_message_t *wrr_value_list_to_message(struct riemann_host const *host, /* {{{ */
404 data_set_t const *ds,
405 value_list_t const *vl,
408 riemann_message_t *msg;
410 gauge_t *rates = NULL;
412 /* Initialize the Msg structure. */
413 msg = riemann_message_new();
416 ERROR ("write_riemann plugin: riemann_message_new failed.");
420 if (host->store_rates)
422 rates = uc_get_rate(ds, vl);
425 ERROR("write_riemann plugin: uc_get_rate failed.");
426 riemann_message_free(msg);
431 for (i = 0; i < vl->values_len; i++)
433 riemann_event_t *event;
435 event = wrr_value_to_event(host, ds, vl,
436 (int) i, rates, statuses[i]);
439 riemann_message_free(msg);
443 riemann_message_append_events(msg, event, NULL);
448 } /* }}} riemann_message_t *wrr_value_list_to_message */
451 * Always call while holding host->lock !
453 static int wrr_batch_flush_nolock(cdtime_t timeout,
454 struct riemann_host *host)
461 if ((host->batch_init + timeout) > now)
464 wrr_send(host, host->batch_msg);
465 riemann_message_free(host->batch_msg);
467 if (host->client_type != RIEMANN_CLIENT_UDP)
469 riemann_message_t *response;
471 response = riemann_client_recv_message(host->client);
475 wrr_disconnect(host);
479 riemann_message_free(response);
482 host->batch_init = cdtime();
483 host->batch_msg = NULL;
487 static int wrr_batch_flush(cdtime_t timeout,
488 const char *identifier __attribute__((unused)),
489 user_data_t *user_data)
491 struct riemann_host *host;
494 if (user_data == NULL)
497 host = user_data->data;
498 pthread_mutex_lock(&host->lock);
499 status = wrr_batch_flush_nolock(timeout, host);
501 c_complain (LOG_ERR, &host->init_complaint,
502 "write_riemann plugin: riemann_client_send failed with status %i",
505 c_release (LOG_DEBUG, &host->init_complaint, "write_riemann plugin: batch sent.");
507 pthread_mutex_unlock(&host->lock);
511 static int wrr_batch_add_value_list(struct riemann_host *host, /* {{{ */
512 data_set_t const *ds,
513 value_list_t const *vl,
516 riemann_message_t *msg;
521 msg = wrr_value_list_to_message(host, ds, vl, statuses);
525 pthread_mutex_lock(&host->lock);
527 if (host->batch_msg == NULL) {
528 host->batch_msg = msg;
532 status = riemann_message_append_events_n(host->batch_msg,
538 riemann_message_free(msg);
541 pthread_mutex_unlock(&host->lock);
542 ERROR("write_riemann plugin: out of memory");
547 len = riemann_message_get_packed_size(host->batch_msg);
549 if ((host->batch_max < 0) || (((size_t) host->batch_max) <= len)) {
550 ret = wrr_batch_flush_nolock(0, host);
552 if (host->batch_timeout > 0) {
553 timeout = TIME_T_TO_CDTIME_T((time_t)host->batch_timeout);
554 ret = wrr_batch_flush_nolock(timeout, host);
558 pthread_mutex_unlock(&host->lock);
560 } /* }}} riemann_message_t *wrr_batch_add_value_list */
562 static int wrr_notification(const notification_t *n, user_data_t *ud) /* {{{ */
565 struct riemann_host *host = ud->data;
566 riemann_message_t *msg;
568 if (!host->notifications)
572 * Never batch for notifications, send them ASAP
574 msg = wrr_notification_to_message(host, n);
578 status = wrr_send(host, msg);
580 c_complain (LOG_ERR, &host->init_complaint,
581 "write_riemann plugin: riemann_client_send failed with status %i",
584 c_release (LOG_DEBUG, &host->init_complaint,
585 "write_riemann plugin: riemann_client_send succeeded");
587 riemann_message_free(msg);
589 } /* }}} int wrr_notification */
591 static int wrr_write(const data_set_t *ds, /* {{{ */
592 const value_list_t *vl,
596 int statuses[vl->values_len];
597 struct riemann_host *host = ud->data;
598 riemann_message_t *msg;
600 if (host->check_thresholds) {
601 status = write_riemann_threshold_check(ds, vl, statuses);
605 memset (statuses, 0, sizeof (statuses));
608 if (host->client_type != RIEMANN_CLIENT_UDP && host->batch_mode) {
609 wrr_batch_add_value_list(host, ds, vl, statuses);
611 msg = wrr_value_list_to_message(host, ds, vl, statuses);
615 status = wrr_send(host, msg);
617 riemann_message_free(msg);
620 } /* }}} int wrr_write */
622 static void wrr_free(void *p) /* {{{ */
624 struct riemann_host *host = p;
629 pthread_mutex_lock(&host->lock);
631 host->reference_count--;
632 if (host->reference_count > 0)
634 pthread_mutex_unlock(&host->lock);
638 wrr_disconnect(host);
640 pthread_mutex_destroy(&host->lock);
642 } /* }}} void wrr_free */
644 static int wrr_config_node(oconfig_item_t *ci) /* {{{ */
646 struct riemann_host *host = NULL;
649 oconfig_item_t *child;
650 char callback_name[DATA_MAX_NAME_LEN];
653 if ((host = calloc(1, sizeof(*host))) == NULL) {
654 ERROR ("write_riemann plugin: calloc failed.");
657 pthread_mutex_init(&host->lock, NULL);
658 C_COMPLAIN_INIT (&host->init_complaint);
659 host->reference_count = 1;
662 host->notifications = 1;
663 host->check_thresholds = 0;
664 host->store_rates = 1;
665 host->always_append_ds = 0;
666 host->batch_mode = 1;
667 host->batch_max = RIEMANN_BATCH_MAX; /* typical MSS */
668 host->batch_init = cdtime();
669 host->batch_timeout = 0;
670 host->ttl_factor = RIEMANN_TTL_FACTOR;
672 host->client_type = RIEMANN_CLIENT_TCP;
673 host->timeout.tv_sec = 0;
674 host->timeout.tv_usec = 0;
676 status = cf_util_get_string(ci, &host->name);
678 WARNING("write_riemann plugin: Required host name is missing.");
683 for (i = 0; i < ci->children_num; i++) {
685 * The code here could be simplified but makes room
686 * for easy adding of new options later on.
688 child = &ci->children[i];
691 if (strcasecmp("Host", child->key) == 0) {
692 status = cf_util_get_string(child, &host->node);
695 } else if (strcasecmp("Notifications", child->key) == 0) {
696 status = cf_util_get_boolean(child, &host->notifications);
699 } else if (strcasecmp("EventServicePrefix", child->key) == 0) {
700 status = cf_util_get_string(child, &host->event_service_prefix);
703 } else if (strcasecmp("CheckThresholds", child->key) == 0) {
704 status = cf_util_get_boolean(child, &host->check_thresholds);
707 } else if (strcasecmp("Batch", child->key) == 0) {
708 status = cf_util_get_boolean(child, &host->batch_mode);
711 } else if (strcasecmp("BatchMaxSize", child->key) == 0) {
712 status = cf_util_get_int(child, &host->batch_max);
715 } else if (strcasecmp("BatchFlushTimeout", child->key) == 0) {
716 status = cf_util_get_int(child, &host->batch_timeout);
719 } else if (strcasecmp("Timeout", child->key) == 0) {
720 status = cf_util_get_int(child, (int *)&host->timeout.tv_sec);
723 } else if (strcasecmp("Port", child->key) == 0) {
724 host->port = cf_util_get_port_number(child);
725 if (host->port == -1) {
726 ERROR("write_riemann plugin: Invalid argument "
727 "configured for the \"Port\" "
731 } else if (strcasecmp("Protocol", child->key) == 0) {
733 status = cf_util_get_string_buffer(child,
737 ERROR("write_riemann plugin: cf_util_get_"
738 "string_buffer failed with "
739 "status %i.", status);
743 if (strcasecmp("UDP", tmp) == 0)
744 host->client_type = RIEMANN_CLIENT_UDP;
745 else if (strcasecmp("TCP", tmp) == 0)
746 host->client_type = RIEMANN_CLIENT_TCP;
747 else if (strcasecmp("TLS", tmp) == 0)
748 host->client_type = RIEMANN_CLIENT_TLS;
750 WARNING("write_riemann plugin: The value "
751 "\"%s\" is not valid for the "
752 "\"Protocol\" option. Use "
753 "either \"UDP\", \"TCP\" or \"TLS\".",
755 } else if (strcasecmp("TLSCAFile", child->key) == 0) {
756 status = cf_util_get_string(child, &host->tls_ca_file);
759 ERROR("write_riemann plugin: cf_util_get_"
760 "string_buffer failed with "
761 "status %i.", status);
764 } else if (strcasecmp("TLSCertFile", child->key) == 0) {
765 status = cf_util_get_string(child, &host->tls_cert_file);
768 ERROR("write_riemann plugin: cf_util_get_"
769 "string_buffer failed with "
770 "status %i.", status);
773 } else if (strcasecmp("TLSKeyFile", child->key) == 0) {
774 status = cf_util_get_string(child, &host->tls_key_file);
777 ERROR("write_riemann plugin: cf_util_get_"
778 "string_buffer failed with "
779 "status %i.", status);
782 } else if (strcasecmp("StoreRates", child->key) == 0) {
783 status = cf_util_get_boolean(child, &host->store_rates);
786 } else if (strcasecmp("AlwaysAppendDS", child->key) == 0) {
787 status = cf_util_get_boolean(child,
788 &host->always_append_ds);
791 } else if (strcasecmp("TTLFactor", child->key) == 0) {
793 status = cf_util_get_double(child, &tmp);
797 host->ttl_factor = tmp;
798 } else if (tmp >= 1.0) {
799 NOTICE("write_riemann plugin: The configured "
800 "TTLFactor is very small "
801 "(%.1f). A value of 2.0 or "
802 "greater is recommended.",
804 host->ttl_factor = tmp;
805 } else if (tmp > 0.0) {
806 WARNING("write_riemann plugin: The configured "
807 "TTLFactor is too small to be "
808 "useful (%.1f). I'll use it "
809 "since the user knows best, "
810 "but under protest.",
812 host->ttl_factor = tmp;
813 } else { /* zero, negative and NAN */
814 ERROR("write_riemann plugin: The configured "
815 "TTLFactor is invalid (%.1f).",
819 WARNING("write_riemann plugin: ignoring unknown config "
820 "option: \"%s\"", child->key);
828 ssnprintf(callback_name, sizeof(callback_name), "write_riemann/%s",
831 ud.free_func = wrr_free;
833 pthread_mutex_lock(&host->lock);
835 status = plugin_register_write(callback_name, wrr_write, &ud);
837 if (host->client_type != RIEMANN_CLIENT_UDP && host->batch_mode) {
839 plugin_register_flush(callback_name, wrr_batch_flush, &ud);
842 WARNING("write_riemann plugin: plugin_register_write (\"%s\") "
843 "failed with status %i.",
844 callback_name, status);
846 host->reference_count++;
848 status = plugin_register_notification(callback_name,
849 wrr_notification, &ud);
851 WARNING("write_riemann plugin: plugin_register_notification (\"%s\") "
852 "failed with status %i.",
853 callback_name, status);
855 host->reference_count++;
857 if (host->reference_count <= 1)
859 /* Both callbacks failed => free memory.
860 * We need to unlock here, because riemann_free() will lock.
861 * This is not a race condition, because we're the only one
862 * holding a reference. */
863 pthread_mutex_unlock(&host->lock);
868 host->reference_count--;
869 pthread_mutex_unlock(&host->lock);
872 } /* }}} int wrr_config_node */
874 static int wrr_config(oconfig_item_t *ci) /* {{{ */
877 oconfig_item_t *child;
880 for (i = 0; i < ci->children_num; i++) {
881 child = &ci->children[i];
883 if (strcasecmp("Node", child->key) == 0) {
884 wrr_config_node (child);
885 } else if (strcasecmp(child->key, "attribute") == 0) {
889 if (child->values_num != 2) {
890 WARNING("riemann attributes need both a key and a value.");
893 if (child->values[0].type != OCONFIG_TYPE_STRING ||
894 child->values[1].type != OCONFIG_TYPE_STRING) {
895 WARNING("riemann attribute needs string arguments.");
898 if ((key = strdup(child->values[0].value.string)) == NULL) {
899 WARNING("cannot allocate memory for attribute key.");
902 if ((val = strdup(child->values[1].value.string)) == NULL) {
903 WARNING("cannot allocate memory for attribute value.");
907 strarray_add(&riemann_attrs, &riemann_attrs_num, key);
908 strarray_add(&riemann_attrs, &riemann_attrs_num, val);
909 DEBUG("write_riemann: got attr: %s => %s", key, val);
912 } else if (strcasecmp(child->key, "tag") == 0) {
914 status = cf_util_get_string(child, &tmp);
918 strarray_add(&riemann_tags, &riemann_tags_num, tmp);
919 DEBUG("write_riemann plugin: Got tag: %s", tmp);
922 WARNING("write_riemann plugin: Ignoring unknown "
923 "configuration option \"%s\" at top level.",
928 } /* }}} int wrr_config */
930 void module_register(void)
932 plugin_register_complex_config("write_riemann", wrr_config);
935 /* vim: set sw=8 sts=8 ts=8 noet : */