X-Git-Url: https://git.octo.it/?a=blobdiff_plain;f=src%2Fcurl_xml.c;h=46e0d490967456156863413912fe234deeb5abda;hb=37392e3b7b8f9c2b7b2c601cec5b879d9a75116e;hp=c10955cb973a803902968781cdc73573d32f46b4;hpb=a24baf2ad70837ea46cacbfee6e03537cf284ad5;p=collectd.git diff --git a/src/curl_xml.c b/src/curl_xml.c index c10955cb..46e0d490 100644 --- a/src/curl_xml.c +++ b/src/curl_xml.c @@ -419,7 +419,8 @@ static int cx_handle_instance_xpath (xmlXPathContextPtr xpath_ctx, /* {{{ */ return (0); } /* }}} int cx_handle_instance_xpath */ -static int cx_handle_base_xpath (char *plugin_instance, /* {{{ */ +static int cx_handle_base_xpath (char const *plugin_instance, /* {{{ */ + char const *host, xmlXPathContextPtr xpath_ctx, const data_set_t *ds, char *base_xpath, cx_xpath_t *xpath) { @@ -461,7 +462,7 @@ static int cx_handle_base_xpath (char *plugin_instance, /* {{{ */ vl.values_len = ds->ds_num; sstrncpy (vl.type, xpath->type, sizeof (vl.type)); sstrncpy (vl.plugin, "curl_xml", sizeof (vl.plugin)); - sstrncpy (vl.host, hostname_g, sizeof (vl.host)); + sstrncpy (vl.host, (host != NULL) ? host : hostname_g, sizeof (vl.host)); if (plugin_instance != NULL) sstrncpy (vl.plugin_instance, plugin_instance, sizeof (vl.plugin_instance)); @@ -504,7 +505,8 @@ static int cx_handle_parsed_xml(xmlDocPtr doc, /* {{{ */ ds = plugin_get_ds (xpath->type); if ( (cx_check_type(ds, xpath) == 0) && - (cx_handle_base_xpath(db->instance, xpath_ctx, ds, le->key, xpath) == 0) ) + (cx_handle_base_xpath(db->instance, db->host, + xpath_ctx, ds, le->key, xpath) == 0) ) status = 0; /* we got atleast one success */ le = le->next; @@ -555,7 +557,8 @@ static int cx_curl_perform (cx_t *db, CURL *curl) /* {{{ */ curl_easy_getinfo(curl, CURLINFO_EFFECTIVE_URL, &url); curl_easy_getinfo(curl, CURLINFO_RESPONSE_CODE, &rc); - if (rc != 200) + /* The response code is zero if a non-HTTP transport was used. */ + if ((rc != 0) && (rc != 200)) { ERROR ("curl_xml plugin: curl_easy_perform failed with response code %ld (%s)", rc, url); @@ -734,6 +737,7 @@ static int cx_init_curl (cx_t *db) /* {{{ */ return (-1); } + curl_easy_setopt (db->curl, CURLOPT_NOSIGNAL, 1); curl_easy_setopt (db->curl, CURLOPT_WRITEFUNCTION, cx_curl_callback); curl_easy_setopt (db->curl, CURLOPT_WRITEDATA, db); curl_easy_setopt (db->curl, CURLOPT_USERAGENT,