2 * collectd - src/write_http.c
3 * Copyright (C) 2009 Paul Sadauskas
4 * Copyright (C) 2009 Doug MacEachern
5 * Copyright (C) 2007-2014 Florian octo Forster
7 * This program is free software; you can redistribute it and/or modify it
8 * under the terms of the GNU General Public License as published by the
9 * Free Software Foundation; only version 2 of the License is applicable.
11 * This program is distributed in the hope that it will be useful, but
12 * WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * General Public License for more details.
16 * You should have received a copy of the GNU General Public License along
17 * with this program; if not, write to the Free Software Foundation, Inc.,
18 * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
21 * Florian octo Forster <octo at collectd.org>
22 * Doug MacEachern <dougm@hyperic.com>
23 * Paul Sadauskas <psadauskas@gmail.com>
30 #include "utils_format_json.h"
31 #include "utils_format_kairosdb.h"
33 #include <curl/curl.h>
35 #ifndef WRITE_HTTP_DEFAULT_BUFFER_SIZE
36 #define WRITE_HTTP_DEFAULT_BUFFER_SIZE 4096
42 struct wh_callback_s {
60 time_t low_speed_time;
63 #define WH_FORMAT_COMMAND 0
64 #define WH_FORMAT_JSON 1
65 #define WH_FORMAT_KAIROSDB 2
68 _Bool send_notifications;
71 struct curl_slist *headers;
72 char curl_errbuf[CURL_ERROR_SIZE];
75 size_t send_buffer_size;
76 size_t send_buffer_free;
77 size_t send_buffer_fill;
78 cdtime_t send_buffer_init_time;
80 pthread_mutex_t send_lock;
82 typedef struct wh_callback_s wh_callback_t;
84 static char **http_attrs;
85 static size_t http_attrs_num;
87 static void wh_log_http_error(wh_callback_t *cb) {
88 if (!cb->log_http_error)
93 curl_easy_getinfo(cb->curl, CURLINFO_RESPONSE_CODE, &http_code);
96 INFO("write_http plugin: HTTP Error code: %lu", http_code);
99 static void wh_reset_buffer(wh_callback_t *cb) /* {{{ */
101 if ((cb == NULL) || (cb->send_buffer == NULL))
104 memset(cb->send_buffer, 0, cb->send_buffer_size);
105 cb->send_buffer_free = cb->send_buffer_size;
106 cb->send_buffer_fill = 0;
107 cb->send_buffer_init_time = cdtime();
109 if (cb->format == WH_FORMAT_JSON || cb->format == WH_FORMAT_KAIROSDB) {
110 format_json_initialize(cb->send_buffer, &cb->send_buffer_fill,
111 &cb->send_buffer_free);
113 } /* }}} wh_reset_buffer */
115 /* must hold cb->send_lock when calling */
116 static int wh_post_nolock(wh_callback_t *cb, char const *data) /* {{{ */
120 curl_easy_setopt(cb->curl, CURLOPT_POSTFIELDS, data);
121 status = curl_easy_perform(cb->curl);
123 wh_log_http_error(cb);
125 if (status != CURLE_OK) {
126 ERROR("write_http plugin: curl_easy_perform failed with "
128 status, cb->curl_errbuf);
131 } /* }}} wh_post_nolock */
133 static int wh_callback_init(wh_callback_t *cb) /* {{{ */
135 if (cb->curl != NULL)
138 cb->curl = curl_easy_init();
139 if (cb->curl == NULL) {
140 ERROR("curl plugin: curl_easy_init failed.");
144 if (cb->low_speed_limit > 0 && cb->low_speed_time > 0) {
145 curl_easy_setopt(cb->curl, CURLOPT_LOW_SPEED_LIMIT,
146 (long)(cb->low_speed_limit * cb->low_speed_time));
147 curl_easy_setopt(cb->curl, CURLOPT_LOW_SPEED_TIME,
148 (long)cb->low_speed_time);
151 #ifdef HAVE_CURLOPT_TIMEOUT_MS
153 curl_easy_setopt(cb->curl, CURLOPT_TIMEOUT_MS, (long)cb->timeout);
156 curl_easy_setopt(cb->curl, CURLOPT_NOSIGNAL, 1L);
157 curl_easy_setopt(cb->curl, CURLOPT_USERAGENT, COLLECTD_USERAGENT);
159 cb->headers = curl_slist_append(cb->headers, "Accept: */*");
160 if (cb->format == WH_FORMAT_JSON || cb->format == WH_FORMAT_KAIROSDB)
162 curl_slist_append(cb->headers, "Content-Type: application/json");
164 cb->headers = curl_slist_append(cb->headers, "Content-Type: text/plain");
165 cb->headers = curl_slist_append(cb->headers, "Expect:");
166 curl_easy_setopt(cb->curl, CURLOPT_HTTPHEADER, cb->headers);
168 curl_easy_setopt(cb->curl, CURLOPT_ERRORBUFFER, cb->curl_errbuf);
169 curl_easy_setopt(cb->curl, CURLOPT_URL, cb->location);
170 curl_easy_setopt(cb->curl, CURLOPT_FOLLOWLOCATION, 1L);
171 curl_easy_setopt(cb->curl, CURLOPT_MAXREDIRS, 50L);
173 if (cb->user != NULL) {
174 #ifdef HAVE_CURLOPT_USERNAME
175 curl_easy_setopt(cb->curl, CURLOPT_USERNAME, cb->user);
176 curl_easy_setopt(cb->curl, CURLOPT_PASSWORD,
177 (cb->pass == NULL) ? "" : cb->pass);
179 size_t credentials_size;
181 credentials_size = strlen(cb->user) + 2;
182 if (cb->pass != NULL)
183 credentials_size += strlen(cb->pass);
185 cb->credentials = malloc(credentials_size);
186 if (cb->credentials == NULL) {
187 ERROR("curl plugin: malloc failed.");
191 ssnprintf(cb->credentials, credentials_size, "%s:%s", cb->user,
192 (cb->pass == NULL) ? "" : cb->pass);
193 curl_easy_setopt(cb->curl, CURLOPT_USERPWD, cb->credentials);
195 curl_easy_setopt(cb->curl, CURLOPT_HTTPAUTH, CURLAUTH_ANY);
198 curl_easy_setopt(cb->curl, CURLOPT_SSL_VERIFYPEER, (long)cb->verify_peer);
199 curl_easy_setopt(cb->curl, CURLOPT_SSL_VERIFYHOST, cb->verify_host ? 2L : 0L);
200 curl_easy_setopt(cb->curl, CURLOPT_SSLVERSION, cb->sslversion);
201 if (cb->cacert != NULL)
202 curl_easy_setopt(cb->curl, CURLOPT_CAINFO, cb->cacert);
203 if (cb->capath != NULL)
204 curl_easy_setopt(cb->curl, CURLOPT_CAPATH, cb->capath);
206 if (cb->clientkey != NULL && cb->clientcert != NULL) {
207 curl_easy_setopt(cb->curl, CURLOPT_SSLKEY, cb->clientkey);
208 curl_easy_setopt(cb->curl, CURLOPT_SSLCERT, cb->clientcert);
210 if (cb->clientkeypass != NULL)
211 curl_easy_setopt(cb->curl, CURLOPT_SSLKEYPASSWD, cb->clientkeypass);
217 } /* }}} int wh_callback_init */
219 static int wh_flush_nolock(cdtime_t timeout, wh_callback_t *cb) /* {{{ */
223 DEBUG("write_http plugin: wh_flush_nolock: timeout = %.3f; "
224 "send_buffer_fill = %zu;",
225 CDTIME_T_TO_DOUBLE(timeout), cb->send_buffer_fill);
227 /* timeout == 0 => flush unconditionally */
232 if ((cb->send_buffer_init_time + timeout) > now)
236 if (cb->format == WH_FORMAT_COMMAND) {
237 if (cb->send_buffer_fill == 0) {
238 cb->send_buffer_init_time = cdtime();
242 status = wh_post_nolock(cb, cb->send_buffer);
244 } else if (cb->format == WH_FORMAT_JSON || cb->format == WH_FORMAT_KAIROSDB) {
245 if (cb->send_buffer_fill <= 2) {
246 cb->send_buffer_init_time = cdtime();
250 status = format_json_finalize(cb->send_buffer, &cb->send_buffer_fill,
251 &cb->send_buffer_free);
253 ERROR("write_http: wh_flush_nolock: "
254 "format_json_finalize failed.");
259 status = wh_post_nolock(cb, cb->send_buffer);
262 ERROR("write_http: wh_flush_nolock: "
263 "Unknown format: %i",
269 } /* }}} wh_flush_nolock */
271 static int wh_flush(cdtime_t timeout, /* {{{ */
272 const char *identifier __attribute__((unused)),
273 user_data_t *user_data) {
277 if (user_data == NULL)
280 cb = user_data->data;
282 pthread_mutex_lock(&cb->send_lock);
284 if (wh_callback_init(cb) != 0) {
285 ERROR("write_http plugin: wh_callback_init failed.");
286 pthread_mutex_unlock(&cb->send_lock);
290 status = wh_flush_nolock(timeout, cb);
291 pthread_mutex_unlock(&cb->send_lock);
294 } /* }}} int wh_flush */
296 static void wh_callback_free(void *data) /* {{{ */
305 if (cb->send_buffer != NULL)
306 wh_flush_nolock(/* timeout = */ 0, cb);
308 if (cb->curl != NULL) {
309 curl_easy_cleanup(cb->curl);
313 if (cb->headers != NULL) {
314 curl_slist_free_all(cb->headers);
322 sfree(cb->credentials);
325 sfree(cb->clientkey);
326 sfree(cb->clientcert);
327 sfree(cb->clientkeypass);
328 sfree(cb->send_buffer);
331 } /* }}} void wh_callback_free */
333 static int wh_write_command(const data_set_t *ds,
334 const value_list_t *vl, /* {{{ */
336 char key[10 * DATA_MAX_NAME_LEN];
343 /* sanity checks, primarily to make static analyzers happy. */
344 if ((cb == NULL) || (cb->send_buffer == NULL))
347 if (strcmp(ds->type, vl->type) != 0) {
348 ERROR("write_http plugin: DS type does not match "
353 /* Copy the identifier to `key' and escape it. */
354 status = FORMAT_VL(key, sizeof(key), vl);
356 ERROR("write_http plugin: error with format_name");
359 escape_string(key, sizeof(key));
361 /* Convert the values to an ASCII representation and put that into
363 status = format_values(values, sizeof(values), ds, vl, cb->store_rates);
365 ERROR("write_http plugin: error with "
366 "wh_value_list_to_string");
370 command_len = (size_t)ssnprintf(command, sizeof(command),
371 "PUTVAL %s interval=%.3f %s\r\n", key,
372 CDTIME_T_TO_DOUBLE(vl->interval), values);
373 if (command_len >= sizeof(command)) {
374 ERROR("write_http plugin: Command buffer too small: "
380 pthread_mutex_lock(&cb->send_lock);
381 if (wh_callback_init(cb) != 0) {
382 ERROR("write_http plugin: wh_callback_init failed.");
383 pthread_mutex_unlock(&cb->send_lock);
387 if (command_len >= cb->send_buffer_free) {
388 status = wh_flush_nolock(/* timeout = */ 0, cb);
390 pthread_mutex_unlock(&cb->send_lock);
394 assert(command_len < cb->send_buffer_free);
396 /* Make scan-build happy. */
397 assert(cb->send_buffer != NULL);
399 /* `command_len + 1' because `command_len' does not include the
400 * trailing null byte. Neither does `send_buffer_fill'. */
401 memcpy(cb->send_buffer + cb->send_buffer_fill, command, command_len + 1);
402 cb->send_buffer_fill += command_len;
403 cb->send_buffer_free -= command_len;
405 DEBUG("write_http plugin: <%s> buffer %zu/%zu (%g%%) \"%s\"", cb->location,
406 cb->send_buffer_fill, cb->send_buffer_size,
407 100.0 * ((double)cb->send_buffer_fill) / ((double)cb->send_buffer_size),
410 /* Check if we have enough space for this command. */
411 pthread_mutex_unlock(&cb->send_lock);
414 } /* }}} int wh_write_command */
416 static int wh_write_json(const data_set_t *ds, const value_list_t *vl, /* {{{ */
420 pthread_mutex_lock(&cb->send_lock);
421 if (wh_callback_init(cb) != 0) {
422 ERROR("write_http plugin: wh_callback_init failed.");
423 pthread_mutex_unlock(&cb->send_lock);
428 format_json_value_list(cb->send_buffer, &cb->send_buffer_fill,
429 &cb->send_buffer_free, ds, vl, cb->store_rates);
430 if (status == -ENOMEM) {
431 status = wh_flush_nolock(/* timeout = */ 0, cb);
434 pthread_mutex_unlock(&cb->send_lock);
439 format_json_value_list(cb->send_buffer, &cb->send_buffer_fill,
440 &cb->send_buffer_free, ds, vl, cb->store_rates);
443 pthread_mutex_unlock(&cb->send_lock);
447 DEBUG("write_http plugin: <%s> buffer %zu/%zu (%g%%)", cb->location,
448 cb->send_buffer_fill, cb->send_buffer_size,
449 100.0 * ((double)cb->send_buffer_fill) /
450 ((double)cb->send_buffer_size));
452 /* Check if we have enough space for this command. */
453 pthread_mutex_unlock(&cb->send_lock);
456 } /* }}} int wh_write_json */
458 static int wh_write_kairosdb(const data_set_t *ds,
459 const value_list_t *vl, /* {{{ */
463 pthread_mutex_lock(&cb->send_lock);
465 if (cb->curl == NULL) {
466 status = wh_callback_init(cb);
468 ERROR("write_http plugin: wh_callback_init failed.");
469 pthread_mutex_unlock(&cb->send_lock);
474 status = format_kairosdb_value_list(
475 cb->send_buffer, &cb->send_buffer_fill, &cb->send_buffer_free, ds, vl,
476 cb->store_rates, (char const *const *)http_attrs, http_attrs_num);
477 if (status == -ENOMEM) {
478 status = wh_flush_nolock(/* timeout = */ 0, cb);
481 pthread_mutex_unlock(&cb->send_lock);
485 status = format_kairosdb_value_list(
486 cb->send_buffer, &cb->send_buffer_fill, &cb->send_buffer_free, ds, vl,
487 cb->store_rates, (char const *const *)http_attrs, http_attrs_num);
490 pthread_mutex_unlock(&cb->send_lock);
494 DEBUG("write_http plugin: <%s> buffer %zu/%zu (%g%%)", cb->location,
495 cb->send_buffer_fill, cb->send_buffer_size,
496 100.0 * ((double)cb->send_buffer_fill) /
497 ((double)cb->send_buffer_size));
499 /* Check if we have enough space for this command. */
500 pthread_mutex_unlock(&cb->send_lock);
503 } /* }}} int wh_write_kairosdb */
505 static int wh_write(const data_set_t *ds, const value_list_t *vl, /* {{{ */
506 user_data_t *user_data) {
510 if (user_data == NULL)
513 cb = user_data->data;
514 assert(cb->send_metrics);
516 switch (cb->format) {
518 status = wh_write_json(ds, vl, cb);
520 case WH_FORMAT_KAIROSDB:
521 status = wh_write_kairosdb(ds, vl, cb);
524 status = wh_write_command(ds, vl, cb);
528 } /* }}} int wh_write */
530 static int wh_notify(notification_t const *n, user_data_t *ud) /* {{{ */
536 if ((ud == NULL) || (ud->data == NULL))
540 assert(cb->send_notifications);
542 status = format_json_notification(alert, sizeof(alert), n);
544 ERROR("write_http plugin: formatting notification failed");
548 pthread_mutex_lock(&cb->send_lock);
549 if (wh_callback_init(cb) != 0) {
550 ERROR("write_http plugin: wh_callback_init failed.");
551 pthread_mutex_unlock(&cb->send_lock);
555 status = wh_post_nolock(cb, alert);
556 pthread_mutex_unlock(&cb->send_lock);
559 } /* }}} int wh_notify */
561 static int config_set_format(wh_callback_t *cb, /* {{{ */
562 oconfig_item_t *ci) {
565 if ((ci->values_num != 1) || (ci->values[0].type != OCONFIG_TYPE_STRING)) {
566 WARNING("write_http plugin: The `%s' config option "
567 "needs exactly one string argument.",
572 string = ci->values[0].value.string;
573 if (strcasecmp("Command", string) == 0)
574 cb->format = WH_FORMAT_COMMAND;
575 else if (strcasecmp("JSON", string) == 0)
576 cb->format = WH_FORMAT_JSON;
577 else if (strcasecmp("KAIROSDB", string) == 0)
578 cb->format = WH_FORMAT_KAIROSDB;
580 ERROR("write_http plugin: Invalid format string: %s", string);
585 } /* }}} int config_set_format */
587 static int wh_config_append_string(const char *name,
588 struct curl_slist **dest, /* {{{ */
589 oconfig_item_t *ci) {
590 struct curl_slist *temp = NULL;
591 if ((ci->values_num != 1) || (ci->values[0].type != OCONFIG_TYPE_STRING)) {
592 WARNING("write_http plugin: `%s' needs exactly one string argument.", name);
596 temp = curl_slist_append(*dest, ci->values[0].value.string);
603 } /* }}} int wh_config_append_string */
605 static int wh_config_node(oconfig_item_t *ci) /* {{{ */
609 char callback_name[DATA_MAX_NAME_LEN];
612 cb = calloc(1, sizeof(*cb));
614 ERROR("write_http plugin: calloc failed.");
619 cb->format = WH_FORMAT_COMMAND;
620 cb->sslversion = CURL_SSLVERSION_DEFAULT;
621 cb->low_speed_limit = 0;
623 cb->log_http_error = 0;
625 cb->send_metrics = 1;
626 cb->send_notifications = 0;
628 pthread_mutex_init(&cb->send_lock, /* attr = */ NULL);
630 cf_util_get_string(ci, &cb->name);
632 /* FIXME: Remove this legacy mode in version 6. */
633 if (strcasecmp("URL", ci->key) == 0)
634 cf_util_get_string(ci, &cb->location);
636 for (int i = 0; i < ci->children_num; i++) {
637 oconfig_item_t *child = ci->children + i;
639 if (strcasecmp("URL", child->key) == 0)
640 status = cf_util_get_string(child, &cb->location);
641 else if (strcasecmp("User", child->key) == 0)
642 status = cf_util_get_string(child, &cb->user);
643 else if (strcasecmp("Password", child->key) == 0)
644 status = cf_util_get_string(child, &cb->pass);
645 else if (strcasecmp("VerifyPeer", child->key) == 0)
646 status = cf_util_get_boolean(child, &cb->verify_peer);
647 else if (strcasecmp("VerifyHost", child->key) == 0)
648 status = cf_util_get_boolean(child, &cb->verify_host);
649 else if (strcasecmp("CACert", child->key) == 0)
650 status = cf_util_get_string(child, &cb->cacert);
651 else if (strcasecmp("CAPath", child->key) == 0)
652 status = cf_util_get_string(child, &cb->capath);
653 else if (strcasecmp("ClientKey", child->key) == 0)
654 status = cf_util_get_string(child, &cb->clientkey);
655 else if (strcasecmp("ClientCert", child->key) == 0)
656 status = cf_util_get_string(child, &cb->clientcert);
657 else if (strcasecmp("ClientKeyPass", child->key) == 0)
658 status = cf_util_get_string(child, &cb->clientkeypass);
659 else if (strcasecmp("SSLVersion", child->key) == 0) {
662 status = cf_util_get_string(child, &value);
666 if (value == NULL || strcasecmp("default", value) == 0)
667 cb->sslversion = CURL_SSLVERSION_DEFAULT;
668 else if (strcasecmp("SSLv2", value) == 0)
669 cb->sslversion = CURL_SSLVERSION_SSLv2;
670 else if (strcasecmp("SSLv3", value) == 0)
671 cb->sslversion = CURL_SSLVERSION_SSLv3;
672 else if (strcasecmp("TLSv1", value) == 0)
673 cb->sslversion = CURL_SSLVERSION_TLSv1;
674 #if (LIBCURL_VERSION_MAJOR > 7) || \
675 (LIBCURL_VERSION_MAJOR == 7 && LIBCURL_VERSION_MINOR >= 34)
676 else if (strcasecmp("TLSv1_0", value) == 0)
677 cb->sslversion = CURL_SSLVERSION_TLSv1_0;
678 else if (strcasecmp("TLSv1_1", value) == 0)
679 cb->sslversion = CURL_SSLVERSION_TLSv1_1;
680 else if (strcasecmp("TLSv1_2", value) == 0)
681 cb->sslversion = CURL_SSLVERSION_TLSv1_2;
684 ERROR("write_http plugin: Invalid SSLVersion "
691 } else if (strcasecmp("Format", child->key) == 0)
692 status = config_set_format(cb, child);
693 else if (strcasecmp("Metrics", child->key) == 0)
694 cf_util_get_boolean(child, &cb->send_metrics);
695 else if (strcasecmp("Notifications", child->key) == 0)
696 cf_util_get_boolean(child, &cb->send_notifications);
697 else if (strcasecmp("StoreRates", child->key) == 0)
698 status = cf_util_get_boolean(child, &cb->store_rates);
699 else if (strcasecmp("BufferSize", child->key) == 0)
700 status = cf_util_get_int(child, &buffer_size);
701 else if (strcasecmp("LowSpeedLimit", child->key) == 0)
702 status = cf_util_get_int(child, &cb->low_speed_limit);
703 else if (strcasecmp("Timeout", child->key) == 0)
704 status = cf_util_get_int(child, &cb->timeout);
705 else if (strcasecmp("LogHttpError", child->key) == 0)
706 status = cf_util_get_boolean(child, &cb->log_http_error);
707 else if (strcasecmp("Header", child->key) == 0)
708 status = wh_config_append_string("Header", &cb->headers, child);
709 else if (strcasecmp("Attribute", child->key) == 0) {
713 if (child->values_num != 2) {
714 WARNING("write_http plugin: Attribute need both a key and a value.");
717 if (child->values[0].type != OCONFIG_TYPE_STRING ||
718 child->values[1].type != OCONFIG_TYPE_STRING) {
719 WARNING("write_http plugin: Attribute needs string arguments.");
722 if ((key = strdup(child->values[0].value.string)) == NULL) {
723 WARNING("cannot allocate memory for attribute key.");
726 if ((val = strdup(child->values[1].value.string)) == NULL) {
727 WARNING("cannot allocate memory for attribute value.");
731 strarray_add(&http_attrs, &http_attrs_num, key);
732 strarray_add(&http_attrs, &http_attrs_num, val);
733 DEBUG("write_http plugin: got attribute: %s => %s", key, val);
737 ERROR("write_http plugin: Invalid configuration "
748 wh_callback_free(cb);
752 if (cb->location == NULL) {
753 ERROR("write_http plugin: no URL defined for instance '%s'", cb->name);
754 wh_callback_free(cb);
758 if (!cb->send_metrics && !cb->send_notifications) {
759 ERROR("write_http plugin: Neither metrics nor notifications "
760 "are enabled for \"%s\".",
762 wh_callback_free(cb);
766 if (cb->low_speed_limit > 0)
767 cb->low_speed_time = CDTIME_T_TO_TIME_T(plugin_get_interval());
769 /* Determine send_buffer_size. */
770 cb->send_buffer_size = WRITE_HTTP_DEFAULT_BUFFER_SIZE;
771 if (buffer_size >= 1024)
772 cb->send_buffer_size = (size_t)buffer_size;
773 else if (buffer_size != 0)
774 ERROR("write_http plugin: Ignoring invalid BufferSize setting (%d).",
777 /* Allocate the buffer. */
778 cb->send_buffer = malloc(cb->send_buffer_size);
779 if (cb->send_buffer == NULL) {
780 ERROR("write_http plugin: malloc(%zu) failed.", cb->send_buffer_size);
781 wh_callback_free(cb);
784 /* Nulls the buffer and sets ..._free and ..._fill. */
787 ssnprintf(callback_name, sizeof(callback_name), "write_http/%s", cb->name);
788 DEBUG("write_http: Registering write callback '%s' with URL '%s'",
789 callback_name, cb->location);
791 user_data_t user_data = {
792 .data = cb, .free_func = wh_callback_free,
795 if (cb->send_metrics) {
796 plugin_register_write(callback_name, wh_write, &user_data);
797 user_data.free_func = NULL;
799 plugin_register_flush(callback_name, wh_flush, &user_data);
802 if (cb->send_notifications) {
803 plugin_register_notification(callback_name, wh_notify, &user_data);
804 user_data.free_func = NULL;
808 } /* }}} int wh_config_node */
810 static int wh_config(oconfig_item_t *ci) /* {{{ */
812 for (int i = 0; i < ci->children_num; i++) {
813 oconfig_item_t *child = ci->children + i;
815 if (strcasecmp("Node", child->key) == 0)
816 wh_config_node(child);
817 /* FIXME: Remove this legacy mode in version 6. */
818 else if (strcasecmp("URL", child->key) == 0) {
819 WARNING("write_http plugin: Legacy <URL> block found. "
820 "Please use <Node> instead.");
821 wh_config_node(child);
823 ERROR("write_http plugin: Invalid configuration "
830 } /* }}} int wh_config */
832 static int wh_init(void) /* {{{ */
834 /* Call this while collectd is still single-threaded to avoid
835 * initialization issues in libgcrypt. */
836 curl_global_init(CURL_GLOBAL_SSL);
838 } /* }}} int wh_init */
840 void module_register(void) /* {{{ */
842 plugin_register_complex_config("write_http", wh_config);
843 plugin_register_init("write_http", wh_init);
844 } /* }}} void module_register */