summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: daebbbe)
raw | patch | inline | side by side (parent: daebbbe)
author | Brandon Arp <brandon.arp@smartsheet.com> | |
Thu, 24 Mar 2016 23:44:46 +0000 (16:44 -0700) | ||
committer | Brandon Arp <brandon.arp@smartsheet.com> | |
Fri, 15 Apr 2016 18:28:17 +0000 (11:28 -0700) |
src/collectd.conf.in | patch | blob | history | |
src/collectd.conf.pod | patch | blob | history | |
src/write_http.c | patch | blob | history |
diff --git a/src/collectd.conf.in b/src/collectd.conf.in
index 20b17b2db170062f5562560abe303750d9f68995..41d10ee32c8ff13afbfba5c05db00fdf41783cd4 100644 (file)
--- a/src/collectd.conf.in
+++ b/src/collectd.conf.in
# ClientKey "/etc/ssl/client.pem"
# ClientCert "/etc/ssl/client.crt"
# ClientKeyPass "secret"
+# Header "X-Custom-Header: custom_value"
# SSLVersion "TLSv1"
# Format "Command"
# StoreRates false
diff --git a/src/collectd.conf.pod b/src/collectd.conf.pod
index cf7ccd0190e32fa81a2f55ad892bc7a96ee36299..805fce4bd4a7b130662acf671f4f9b79c0ed1fbf 100644 (file)
--- a/src/collectd.conf.pod
+++ b/src/collectd.conf.pod
Password required to load the private key in B<ClientKey>.
+=item B<Header> I<Header>
+
+A HTTP header to add to the request. Multiple headers are added if this option is specified more than once. Example:
+
+ Header "X-Custom-Header: custom_value"
+
=item B<SSLVersion> B<SSLv2>|B<SSLv3>|B<TLSv1>|B<TLSv1_0>|B<TLSv1_1>|B<TLSv1_2>
Define which SSL protocol version must be used. By default C<libcurl> will
diff --git a/src/write_http.c b/src/write_http.c
index ec3a01ce228aeb7798a611333b90fdb9d2b4630d..27337813affbc45dc6d9728f41f3427c78e3ac05 100644 (file)
--- a/src/write_http.c
+++ b/src/write_http.c
curl_easy_setopt (cb->curl, CURLOPT_NOSIGNAL, 1L);
curl_easy_setopt (cb->curl, CURLOPT_USERAGENT, COLLECTD_USERAGENT);
- cb->headers = NULL;
cb->headers = curl_slist_append (cb->headers, "Accept: */*");
if (cb->format == WH_FORMAT_JSON)
cb->headers = curl_slist_append (cb->headers, "Content-Type: application/json");
return (0);
} /* }}} int config_set_format */
+static int wh_config_append_string (const char *name, struct curl_slist **dest, /* {{{ */
+ oconfig_item_t *ci)
+{
+ struct curl_slist *temp = NULL;
+ if ((ci->values_num != 1) || (ci->values[0].type != OCONFIG_TYPE_STRING))
+ {
+ WARNING ("write_http plugin: `%s' needs exactly one string argument.", name);
+ return (-1);
+ }
+
+ temp = curl_slist_append(*dest, ci->values[0].value.string);
+ if (temp == NULL)
+ return (-1);
+
+ *dest = temp;
+
+ return (0);
+} /* }}} int wh_config_append_string */
+
static int wh_config_node (oconfig_item_t *ci) /* {{{ */
{
wh_callback_t *cb;
status = cf_util_get_int (child, &cb->timeout);
else if (strcasecmp ("LogHttpError", child->key) == 0)
status = cf_util_get_boolean (child, &cb->log_http_error);
+ else if (strcasecmp ("Header", child->key) == 0)
+ status = wh_config_append_string ("Header", &cb->headers, child);
else
{
ERROR ("write_http plugin: Invalid configuration "