#include "common.h"
#include "plugin.h"
#include "configfile.h"
+#include "utils_curl_stats.h"
#include "utils_match.h"
#include "utils_time.h"
_Bool response_time;
_Bool response_code;
int timeout;
+ curl_stats_t *stats;
CURL *curl;
char curl_errbuf[CURL_ERROR_SIZE];
size_t len;
len = size * nmemb;
- if (len <= 0)
+ if (len == 0)
return (len);
wp = user_data;
size_t temp_size;
temp_size = wp->buffer_fill + len + 1;
- temp = (char *) realloc (wp->buffer, temp_size);
+ temp = realloc (wp->buffer, temp_size);
if (temp == NULL)
{
ERROR ("curl plugin: realloc failed.");
sfree (wp->cacert);
sfree (wp->post_body);
curl_slist_free_all (wp->headers);
+ curl_stats_destroy (wp->stats);
sfree (wp->buffer);
static int cc_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 ("curl plugin: `%s' needs exactly one string argument.", name);
return (-1);
}
- *dest = curl_slist_append(*dest, ci->values[0].value.string);
- if (*dest == NULL)
+ temp = curl_slist_append(*dest, ci->values[0].value.string);
+ if (temp == NULL)
return (-1);
+ *dest = temp;
+
return (0);
} /* }}} int cc_config_append_string */
match->dstype);
if (match->match == NULL)
{
- ERROR ("curl plugin: tail_match_add_match_simple failed.");
+ ERROR ("curl plugin: match_create_simple failed.");
cc_web_match_free (match);
return (-1);
}
page->response_time = 0;
page->response_code = 0;
page->timeout = -1;
+ page->stats = NULL;
page->instance = strdup (ci->values[0].value.string);
if (page->instance == NULL)
status = cf_util_get_string (child, &page->post_body);
else if (strcasecmp ("Timeout", child->key) == 0)
status = cf_util_get_int (child, &page->timeout);
+ else if (strcasecmp ("Statistics", child->key) == 0) {
+ page->stats = curl_stats_from_config (child);
+ if (page->stats == NULL)
+ status = -1;
+ }
else
{
WARNING ("curl plugin: Option `%s' not allowed here.", child->key);
status = -1;
}
- if (page->matches == NULL && !page->response_time && !page->response_code)
+ if (page->matches == NULL && page->stats == NULL
+ && !page->response_time && !page->response_code)
{
assert (page->instance != NULL);
WARNING ("curl plugin: No (valid) `Match' block "
- "or MeasureResponseTime or MeasureResponseCode within "
- "`Page' block `%s'.", page->instance);
+ "or Statistics or MeasureResponseTime or MeasureResponseCode "
+ "within `Page' block `%s'.", page->instance);
status = -1;
}
web_page_t *prev;
prev = pages_g;
- while ((prev != NULL) && (prev->next != NULL))
+ while (prev->next != NULL)
prev = prev->next;
prev->next = page;
}
if (wp->response_time)
cc_submit_response_time (wp, cdtime() - start);
+ if (wp->stats != NULL)
+ curl_stats_dispatch (wp->stats, wp->curl, hostname_g, "curl", wp->instance);
if(wp->response_code)
{