summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 968d1bd)
raw | patch | inline | side by side (parent: 968d1bd)
author | Paul Sadauskas <psadauskas@gmail.com> | |
Mon, 15 Jun 2009 01:52:18 +0000 (19:52 -0600) | ||
committer | Florian Forster <octo@leeloo.lan.home.verplant.org> | |
Fri, 21 Aug 2009 06:41:53 +0000 (08:41 +0200) |
src/http.c | patch | blob | history |
diff --git a/src/http.c b/src/http.c
index 2cce5803ae1bce27e2b73ef62aa4950302a09425..d58eda47abff8c750ef89afd73cf76c38a3f4a86 100644 (file)
--- a/src/http.c
+++ b/src/http.c
char *pass;
char *credentials;
-CURL *curl;
-char curl_errbuf[CURL_ERROR_SIZE];
-struct curl_slist *headers=NULL;
-
-static int http_init(void)
+static int http_init_curl(CURL *curl, char curl_errbuf[])
{
-
- curl = curl_easy_init ();
- if (curl == NULL)
- {
- ERROR ("curl plugin: curl_easy_init failed.");
- return (-1);
- }
+ struct curl_slist *headers=NULL;
curl_easy_setopt (curl, CURLOPT_USERAGENT, PACKAGE_NAME"/"PACKAGE_VERSION);
- headers = curl_slist_append(headers, "Accept: application/vnd.absperf.ssbe+json");
- headers = curl_slist_append(headers, "Content-Type: text/csv");
+ headers = curl_slist_append(headers, "Accept: text/csv");
+ headers = curl_slist_append(headers, "Content-Type: text/csv");
curl_easy_setopt (curl, CURLOPT_HTTPHEADER, headers);
+
curl_easy_setopt (curl, CURLOPT_ERRORBUFFER, curl_errbuf);
curl_easy_setopt (curl, CURLOPT_URL, location);
return (0);
}
+static int http_init(void)
+{
+ return (0);
+}
+
static int value_list_to_string (char *buffer, int buffer_len,
const data_set_t *ds, const value_list_t *vl, int index)
{
static int http_write (const data_set_t *ds, const value_list_t *vl,
user_data_t __attribute__((unused)) *user_data)
{
+ CURL *curl;
+ char curl_errbuf[CURL_ERROR_SIZE];
+
char metric_name[512];
int metric_prefix_len;
char value[512];
return -1;
}
+ curl = curl_easy_init ();
+ if (curl == NULL)
+ {
+ ERROR ("curl plugin: curl_easy_init failed.");
+ return (-1);
+ }
+
+ http_init_curl(curl, curl_errbuf);
+
metric_prefix_len = value_list_to_metric_name (metric_name,
sizeof (metric_name), ds, vl);