diff --git a/src/apache.c b/src/apache.c
index dd5e2c726dd060b1d886f2ac5e073030ed5c79e2..156ad5dc905d757d2fd2fd05f97c1b5a8e748633 100644 (file)
--- a/src/apache.c
+++ b/src/apache.c
# define APACHE_HAVE_READ 0
#endif
# define APACHE_HAVE_READ 0
#endif
-static char *url = NULL;
-static char *user = NULL;
-static char *pass = NULL;
+static char *url = NULL;
+static char *user = NULL;
+static char *pass = NULL;
+static char *cacert = NULL;
-#if APACHE_HAVE_READ
+#if HAVE_LIBCURL
static CURL *curl = NULL;
static char apache_buffer[4096];
static int apache_buffer_len = 0;
static char apache_curl_error[CURL_ERROR_SIZE];
static CURL *curl = NULL;
static char apache_buffer[4096];
static int apache_buffer_len = 0;
static char apache_curl_error[CURL_ERROR_SIZE];
-#endif
+#endif /* HAVE_LIBCURL */
+/* Limit to 2^27 bytes/s. That's what a gigabit-ethernet link can handle, in
+ * theory. */
static char *bytes_file = "apache/apache_bytes.rrd";
static char *bytes_ds_def[] =
{
static char *bytes_file = "apache/apache_bytes.rrd";
static char *bytes_ds_def[] =
{
- "DS:count:COUNTER:25:0:U",
+ "DS:count:COUNTER:"COLLECTD_HEARTBEAT":0:134217728",
NULL
};
static int bytes_ds_num = 1;
NULL
};
static int bytes_ds_num = 1;
+/* Limit to 2^20 requests/s */
static char *requests_file = "apache/apache_requests.rrd";
static char *requests_ds_def[] =
{
static char *requests_file = "apache/apache_requests.rrd";
static char *requests_ds_def[] =
{
- "DS:count:COUNTER:25:0:U",
+ "DS:count:COUNTER:"COLLECTD_HEARTBEAT":0:1048576",
NULL
};
static int requests_ds_num = 1;
NULL
};
static int requests_ds_num = 1;
static char *scoreboard_file = "apache/apache_scoreboard-%s.rrd";
static char *scoreboard_ds_def[] =
{
static char *scoreboard_file = "apache/apache_scoreboard-%s.rrd";
static char *scoreboard_ds_def[] =
{
- "DS:count:GAUGE:25:0:U",
+ "DS:count:GAUGE:"COLLECTD_HEARTBEAT":0:U",
NULL
};
static int scoreboard_ds_num = 1;
static char *config_keys[] =
{
NULL
};
static int scoreboard_ds_num = 1;
static char *config_keys[] =
{
- "URI",
+ "URL",
"User",
"Password",
"User",
"Password",
+ "CACert",
NULL
};
NULL
};
-static int config_keys_num = 3;
-
+static int config_keys_num = 4;
+#if HAVE_LIBCURL
static size_t apache_curl_callback (void *buf, size_t size, size_t nmemb, void *stream)
{
size_t len = size * nmemb;
static size_t apache_curl_callback (void *buf, size_t size, size_t nmemb, void *stream)
{
size_t len = size * nmemb;
return (len);
}
return (len);
}
+#endif /* HAVE_LIBCURL */
static int config_set (char **var, char *value)
{
static int config_set (char **var, char *value)
{
static int config (char *key, char *value)
{
static int config (char *key, char *value)
{
- if (strcasecmp (key, "uri") == 0)
- return (config_set (&key, value));
+ if (strcasecmp (key, "url") == 0)
+ return (config_set (&url, value));
else if (strcasecmp (key, "user") == 0)
return (config_set (&user, value));
else if (strcasecmp (key, "password") == 0)
return (config_set (&pass, value));
else if (strcasecmp (key, "user") == 0)
return (config_set (&user, value));
else if (strcasecmp (key, "password") == 0)
return (config_set (&pass, value));
+ else if (strcasecmp (key, "cacert") == 0)
+ return (config_set (&cacert, value));
else
return (-1);
}
static void init (void)
{
else
return (-1);
}
static void init (void)
{
-#if APACHE_HAVE_READ
+#if HAVE_LIBCURL
static char credentials[1024];
if (curl != NULL)
static char credentials[1024];
if (curl != NULL)
{
curl_easy_setopt (curl, CURLOPT_URL, url);
}
{
curl_easy_setopt (curl, CURLOPT_URL, url);
}
-#endif /* APACHE_HAVE_READ */
+
+ if (cacert != NULL)
+ {
+ curl_easy_setopt (curl, CURLOPT_CAINFO, cacert);
+ }
+#endif /* HAVE_LIBCURL */
}
static void bytes_write (char *host, char *inst, char *val)
}
static void bytes_write (char *host, char *inst, char *val)
if (url == NULL)
return;
if (url == NULL)
return;
+ apache_buffer_len = 0;
if (curl_easy_perform (curl) != 0)
{
syslog (LOG_WARNING, "apache: curl_easy_perform failed: %s", apache_curl_error);
if (curl_easy_perform (curl) != 0)
{
syslog (LOG_WARNING, "apache: curl_easy_perform failed: %s", apache_curl_error);