Changed the DS of the apache-plugin to contain upper limits. Since logrotate restarts...
[collectd.git] / src / apache.c
index 7bb0a2a..c410dc4 100644 (file)
@@ -46,18 +46,21 @@ static int  apache_buffer_len = 0;
 static char apache_curl_error[CURL_ERROR_SIZE];
 #endif
 
+/* 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[] =
 {
-       "DS:count:COUNTER:25:0:U",
+       "DS:count:COUNTER:"COLLECTD_HEARTBEAT":0:134217728",
        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[] =
 {
-       "DS:count:COUNTER:25:0:U",
+       "DS:count:COUNTER:"COLLECTD_HEARTBEAT":0:1048576",
        NULL
 };
 static int requests_ds_num = 1;
@@ -65,14 +68,14 @@ static int requests_ds_num = 1;
 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[] =
 {
-       "URI",
+       "URL",
        "User",
        "Password",
        NULL
@@ -99,7 +102,7 @@ static size_t apache_curl_callback (void *buf, size_t size, size_t nmemb, void *
        return (len);
 }
 
-static void config_set (char **var, char *value)
+static int config_set (char **var, char *value)
 {
        if (*var != NULL)
        {
@@ -115,8 +118,8 @@ static void config_set (char **var, 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)
@@ -128,14 +131,14 @@ static int config (char *key, char *value)
 static void init (void)
 {
 #if APACHE_HAVE_READ
-       static credentials[1024];
+       static char credentials[1024];
 
        if (curl != NULL)
        {
                curl_easy_cleanup (curl);
        }
 
-       if ((curl = curl_easy_init (CURL_GLOBAL_NOTHING)) == NULL)
+       if ((curl = curl_easy_init ()) == NULL)
        {
                syslog (LOG_ERR, "apache: `curl_easy_init' failed.");
                return;
@@ -255,9 +258,8 @@ static void submit_scoreboard (char *buf)
        submit ("apache_scoreboard", "idle_cleanup", idle_cleanup);
 }
 
-static void read (void)
+static void apache_read (void)
 {
-       CURLcode status;
        int i;
 
        char *ptr;
@@ -274,7 +276,7 @@ static void read (void)
 
        if (curl_easy_perform (curl) != 0)
        {
-               syslog (LOG_WARN, "apache: curl_easy_perform failed: %s", apache_curl_error);
+               syslog (LOG_WARNING, "apache: curl_easy_perform failed: %s", apache_curl_error);
                return;
        }
 
@@ -311,12 +313,12 @@ static void read (void)
        apache_buffer_len = 0;
 }
 #else
-#  define read NULL
+#  define apache_read NULL
 #endif /* APACHE_HAVE_READ */
 
 void module_register (void)
 {
-       plugin_register (MODULE_NAME, init, read, NULL);
+       plugin_register (MODULE_NAME, init, apache_read, NULL);
        plugin_register ("apache_requests",   NULL, NULL, requests_write);
        plugin_register ("apache_bytes",      NULL, NULL, bytes_write);
        plugin_register ("apache_scoreboard", NULL, NULL, scoreboard_write);