author | Ruben Kerkhof <ruben@rubenkerkhof.com> | |
Tue, 4 Jul 2017 15:27:03 +0000 (17:27 +0200) | ||
committer | GitHub <noreply@github.com> | |
Tue, 4 Jul 2017 15:27:03 +0000 (17:27 +0200) |
curl plugins: Use configured URL for all poll cycles
src/apache.c | patch | blob | history | |
src/ascent.c | patch | blob | history | |
src/bind.c | patch | blob | history | |
src/curl.c | patch | blob | history | |
src/curl_json.c | patch | blob | history | |
src/curl_xml.c | patch | blob | history | |
src/nginx.c | patch | blob | history | |
src/write_http.c | patch | blob | history |
diff --git a/src/apache.c b/src/apache.c
index 35e02ab5f9bfb21fa46c6482b6e1db9bb4c87e91..50784e5f1ff9b0d4f31e3fd42fba4e61ac873703 100644 (file)
--- a/src/apache.c
+++ b/src/apache.c
#endif
}
- curl_easy_setopt(st->curl, CURLOPT_URL, st->url);
curl_easy_setopt(st->curl, CURLOPT_FOLLOWLOCATION, 1L);
curl_easy_setopt(st->curl, CURLOPT_MAXREDIRS, 50L);
assert(st->curl != NULL);
st->apache_buffer_fill = 0;
+
+ curl_easy_setopt(st->curl, CURLOPT_URL, st->url);
+
if (curl_easy_perform(st->curl) != CURLE_OK) {
ERROR("apache: curl_easy_perform failed: %s", st->apache_curl_error);
return (-1);
diff --git a/src/ascent.c b/src/ascent.c
index f5c3071a649db242dd12b3c1b85734ad9a9bf249..c41c896fa2c6fc752f5df21a2a707c37f3334cfa 100644 (file)
--- a/src/ascent.c
+++ b/src/ascent.c
#endif
}
- curl_easy_setopt(curl, CURLOPT_URL, url);
curl_easy_setopt(curl, CURLOPT_FOLLOWLOCATION, 1L);
curl_easy_setopt(curl, CURLOPT_MAXREDIRS, 50L);
}
ascent_buffer_fill = 0;
+
+ curl_easy_setopt(curl, CURLOPT_URL, url);
+
if (curl_easy_perform(curl) != CURLE_OK) {
ERROR("ascent plugin: curl_easy_perform failed: %s", ascent_curl_error);
return (-1);
diff --git a/src/bind.c b/src/bind.c
index 853b9c26a352d912d851eee8a6803f8fda42677b..fc1fd92f0385905638e2f750d882b930cdc55b10 100644 (file)
--- a/src/bind.c
+++ b/src/bind.c
curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, bind_curl_callback);
curl_easy_setopt(curl, CURLOPT_USERAGENT, COLLECTD_USERAGENT);
curl_easy_setopt(curl, CURLOPT_ERRORBUFFER, bind_curl_error);
- curl_easy_setopt(curl, CURLOPT_URL, (url != NULL) ? url : BIND_DEFAULT_URL);
curl_easy_setopt(curl, CURLOPT_FOLLOWLOCATION, 1L);
curl_easy_setopt(curl, CURLOPT_MAXREDIRS, 50L);
#ifdef HAVE_CURLOPT_TIMEOUT_MS
}
bind_buffer_fill = 0;
+
+ curl_easy_setopt(curl, CURLOPT_URL, (url != NULL) ? url : BIND_DEFAULT_URL);
+
if (curl_easy_perform(curl) != CURLE_OK) {
ERROR("bind plugin: curl_easy_perform failed: %s", bind_curl_error);
return (-1);
diff --git a/src/curl.c b/src/curl.c
index dfc14dcb3f242ba9f13b2e018fee260618de1398..fc3af6dbbf32cfe9375abb1be8e89a25bce8ced3 100644 (file)
--- a/src/curl.c
+++ b/src/curl.c
curl_easy_setopt(wp->curl, CURLOPT_WRITEDATA, wp);
curl_easy_setopt(wp->curl, CURLOPT_USERAGENT, COLLECTD_USERAGENT);
curl_easy_setopt(wp->curl, CURLOPT_ERRORBUFFER, wp->curl_errbuf);
- curl_easy_setopt(wp->curl, CURLOPT_URL, wp->url);
curl_easy_setopt(wp->curl, CURLOPT_FOLLOWLOCATION, 1L);
curl_easy_setopt(wp->curl, CURLOPT_MAXREDIRS, 50L);
start = cdtime();
wp->buffer_fill = 0;
+
+ curl_easy_setopt(wp->curl, CURLOPT_URL, wp->url);
+
status = curl_easy_perform(wp->curl);
if (status != CURLE_OK) {
ERROR("curl plugin: curl_easy_perform failed with status %i: %s", status,
diff --git a/src/curl_json.c b/src/curl_json.c
index 9cdd4fe80aa9476e4b25d1ea1d0c5d94c92cc62e..c0f9346508214cd5ecb90e89df8f556cb3020c9d 100644 (file)
--- a/src/curl_json.c
+++ b/src/curl_json.c
curl_easy_setopt(db->curl, CURLOPT_WRITEDATA, db);
curl_easy_setopt(db->curl, CURLOPT_USERAGENT, COLLECTD_USERAGENT);
curl_easy_setopt(db->curl, CURLOPT_ERRORBUFFER, db->curl_errbuf);
- curl_easy_setopt(db->curl, CURLOPT_URL, db->url);
curl_easy_setopt(db->curl, CURLOPT_FOLLOWLOCATION, 1L);
curl_easy_setopt(db->curl, CURLOPT_MAXREDIRS, 50L);
int status;
long rc;
char *url;
- url = db->url;
+
+ curl_easy_setopt(db->curl, CURLOPT_URL, db->url);
status = curl_easy_perform(db->curl);
if (status != CURLE_OK) {
ERROR("curl_json plugin: curl_easy_perform failed with status %i: %s (%s)",
- status, db->curl_errbuf, url);
+ status, db->curl_errbuf, db->url);
return (-1);
}
if (db->stats != NULL)
diff --git a/src/curl_xml.c b/src/curl_xml.c
index 169aaf9477d8e01f55a392c7c8fbbbbda776531b..23aa85552ce79a924619ed8c6484d66e49e772f4 100644 (file)
--- a/src/curl_xml.c
+++ b/src/curl_xml.c
long rc;
char *ptr;
char *url;
- url = db->url;
db->buffer_fill = 0;
+
+ curl_easy_setopt(db->curl, CURLOPT_URL, db->url);
+
status = curl_easy_perform(curl);
if (status != CURLE_OK) {
ERROR("curl_xml plugin: curl_easy_perform failed with status %i: %s (%s)",
- status, db->curl_errbuf, url);
+ status, db->curl_errbuf, db->url);
return (-1);
}
if (db->stats != NULL)
curl_easy_setopt(db->curl, CURLOPT_WRITEDATA, db);
curl_easy_setopt(db->curl, CURLOPT_USERAGENT, COLLECTD_USERAGENT);
curl_easy_setopt(db->curl, CURLOPT_ERRORBUFFER, db->curl_errbuf);
- curl_easy_setopt(db->curl, CURLOPT_URL, db->url);
curl_easy_setopt(db->curl, CURLOPT_FOLLOWLOCATION, 1L);
curl_easy_setopt(db->curl, CURLOPT_MAXREDIRS, 50L);
diff --git a/src/nginx.c b/src/nginx.c
index fc935b4aa7c3bdf44a221a582af9a27ad2a09634..e320ea7102cc81ff7c935617c258d600576c28fb 100644 (file)
--- a/src/nginx.c
+++ b/src/nginx.c
#endif
}
- if (url != NULL) {
- curl_easy_setopt(curl, CURLOPT_URL, url);
- }
-
curl_easy_setopt(curl, CURLOPT_FOLLOWLOCATION, 1L);
curl_easy_setopt(curl, CURLOPT_MAXREDIRS, 50L);
return (-1);
nginx_buffer_len = 0;
+
+ curl_easy_setopt(curl, CURLOPT_URL, url);
+
if (curl_easy_perform(curl) != CURLE_OK) {
WARNING("nginx plugin: curl_easy_perform failed: %s", nginx_curl_error);
return (-1);
diff --git a/src/write_http.c b/src/write_http.c
index 6127c0426d2ba4fc36ffdd0d654f564b95b3a829..4a92ac751e118ad80cbc99c277b9cd859e44442c 100644 (file)
--- a/src/write_http.c
+++ b/src/write_http.c
{
int status = 0;
+ curl_easy_setopt(cb->curl, CURLOPT_URL, cb->location);
curl_easy_setopt(cb->curl, CURLOPT_POSTFIELDS, data);
status = curl_easy_perform(cb->curl);
curl_easy_setopt(cb->curl, CURLOPT_HTTPHEADER, cb->headers);
curl_easy_setopt(cb->curl, CURLOPT_ERRORBUFFER, cb->curl_errbuf);
- curl_easy_setopt(cb->curl, CURLOPT_URL, cb->location);
curl_easy_setopt(cb->curl, CURLOPT_FOLLOWLOCATION, 1L);
curl_easy_setopt(cb->curl, CURLOPT_MAXREDIRS, 50L);