diff --git a/src/apache.c b/src/apache.c
index 086a39c814541a658f9d539f5c532860867b07ea..c515e3c5db57a45bc04e706db387d02b5a27ba24 100644 (file)
--- a/src/apache.c
+++ b/src/apache.c
_Bool verify_peer;
_Bool verify_host;
char *cacert;
+ char *ssl_ciphers;
char *server; /* user specific server type */
char *apache_buffer;
char apache_curl_error[CURL_ERROR_SIZE];
sfree (st->user);
sfree (st->pass);
sfree (st->cacert);
+ sfree (st->ssl_ciphers);
sfree (st->server);
sfree (st->apache_buffer);
if (st->curl) {
curl_easy_cleanup(st->curl);
st->curl = NULL;
}
+ sfree (st);
} /* apache_free */
static size_t apache_curl_callback (void *buf, size_t size, size_t nmemb,
status = cf_util_get_boolean (child, &st->verify_host);
else if (strcasecmp ("CACert", child->key) == 0)
status = cf_util_get_string (child, &st->cacert);
+ else if (strcasecmp ("SSLCiphers", child->key) == 0)
+ status = cf_util_get_string (child, &st->ssl_ciphers);
else if (strcasecmp ("Server", child->key) == 0)
status = cf_util_get_string (child, &st->server);
else if (strcasecmp ("Timeout", child->key) == 0)
st->verify_host ? 2L : 0L);
if (st->cacert != NULL)
curl_easy_setopt (st->curl, CURLOPT_CAINFO, st->cacert);
+ if (st->ssl_ciphers != NULL)
+ curl_easy_setopt (st->curl, CURLOPT_SSL_CIPHER_LIST,st->ssl_ciphers);
#ifdef HAVE_CURLOPT_TIMEOUT_MS
if (st->timeout >= 0)
static int apache_read_host (user_data_t *user_data) /* {{{ */
{
- int i;
-
char *ptr;
char *saveptr;
- char *lines[16];
- int lines_num = 0;
+ char *line;
char *fields[4];
int fields_num;
st = user_data->data;
+ int status;
+
+ char *content_type;
+ static const char *text_plain = "text/plain";
+
assert (st->url != NULL);
/* (Assured by `config_add') */
if (st->curl == NULL)
{
- int status;
-
status = init_host (st);
if (status != 0)
return (-1);
st->server_type = APACHE;
}
- ptr = st->apache_buffer;
- saveptr = NULL;
- while ((lines[lines_num] = strtok_r (ptr, "\n\r", &saveptr)) != NULL)
+ status = curl_easy_getinfo (st->curl, CURLINFO_CONTENT_TYPE, &content_type);
+ if ((status == CURLE_OK) && (content_type != NULL) &&
+ (strncasecmp (content_type, text_plain, strlen (text_plain)) != 0))
{
- ptr = NULL;
- lines_num++;
-
- if (lines_num >= 16)
- break;
+ WARNING ("apache plugin: `Content-Type' response header is not `%s' "
+ "(received: `%s'). Expecting unparseable data. Please check `URL' "
+ "parameter (missing `?auto' suffix ?)",
+ text_plain, content_type);
}
- for (i = 0; i < lines_num; i++)
+ ptr = st->apache_buffer;
+ saveptr = NULL;
+ while ((line = strtok_r (ptr, "\n\r", &saveptr)) != NULL)
{
- fields_num = strsplit (lines[i], fields, 4);
+ ptr = NULL;
+ fields_num = strsplit (line, fields, STATIC_ARRAY_SIZE (fields));
if (fields_num == 3)
{
- if ((strcmp (fields[0], "Total") == 0)
- && (strcmp (fields[1], "Accesses:") == 0))
- submit_derive ("apache_requests", "",
- atoll (fields[2]), st);
- else if ((strcmp (fields[0], "Total") == 0)
- && (strcmp (fields[1], "kBytes:") == 0))
- submit_derive ("apache_bytes", "",
- 1024LL * atoll (fields[2]), st);
+ if ((strcmp (fields[0], "Total") == 0) && (strcmp (fields[1], "Accesses:") == 0))
+ submit_derive ("apache_requests", "", atoll (fields[2]), st);
+ else if ((strcmp (fields[0], "Total") == 0) && (strcmp (fields[1], "kBytes:") == 0))
+ submit_derive ("apache_bytes", "", 1024LL * atoll (fields[2]), st);
}
else if (fields_num == 2)
{