X-Git-Url: https://git.octo.it/?a=blobdiff_plain;f=src%2Fapache.c;h=7c48f085bcd02924354115a342bd29f6ffeb8b7d;hb=3a4405009e53f578c26c22073920cc5b4ffa6eca;hp=156ad5dc905d757d2fd2fd05f97c1b5a8e748633;hpb=f17fc1f1e4091ab249f88bfc00109c2a90a9bd6a;p=collectd.git diff --git a/src/apache.c b/src/apache.c index 156ad5dc..7c48f085 100644 --- a/src/apache.c +++ b/src/apache.c @@ -1,6 +1,7 @@ /** * collectd - src/apache.c * Copyright (C) 2006 Florian octo Forster + * Copyright (C) 2007 Florent EppO Monbillard * * This program is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License as published by the @@ -18,6 +19,8 @@ * * Authors: * Florian octo Forster + * Florent EppO Monbillard + * - connections/lighttpd extension **/ #include "collectd.h" @@ -42,7 +45,8 @@ static char *cacert = NULL; #if HAVE_LIBCURL static CURL *curl = NULL; -static char apache_buffer[4096]; +#define ABUFFER_SIZE 16384 +static char apache_buffer[ABUFFER_SIZE]; static int apache_buffer_len = 0; static char apache_curl_error[CURL_ERROR_SIZE]; #endif /* HAVE_LIBCURL */ @@ -74,6 +78,15 @@ static char *scoreboard_ds_def[] = }; static int scoreboard_ds_num = 1; +/* for lighttpd; Limit to 65536 active connections */ +static char *connections_file = "apache/apache_connections.rrd"; +static char *connections_ds_def[] = +{ + "DS:connections:GAUGE:"COLLECTD_HEARTBEAT":0:65536", + NULL +}; +static int connections_ds_num = 1; + static char *config_keys[] = { "URL", @@ -89,9 +102,9 @@ static size_t apache_curl_callback (void *buf, size_t size, size_t nmemb, void * { size_t len = size * nmemb; - if ((apache_buffer_len + len) >= 4096) + if ((apache_buffer_len + len) >= ABUFFER_SIZE) { - len = 4095 - apache_buffer_len; + len = (ABUFFER_SIZE - 1) - apache_buffer_len; } if (len <= 0) @@ -196,6 +209,12 @@ static void scoreboard_write (char *host, char *inst, char *val) rrd_update_file (host, buf, val, scoreboard_ds_def, scoreboard_ds_num); } +static void connections_write (char *host, char *inst, char *val) +{ + rrd_update_file (host, connections_file, val, connections_ds_def, + connections_ds_num); +} + #if APACHE_HAVE_READ static void submit (char *type, char *inst, long long value) { @@ -318,6 +337,8 @@ static void apache_read (void) { if (strcmp (fields[0], "Scoreboard:") == 0) submit_scoreboard (fields[1]); + else if (strcmp (fields[0], "BusyServers:") == 0) + submit ("apache_connections", NULL, atol (fields[1])); } } @@ -333,6 +354,7 @@ void module_register (void) plugin_register ("apache_requests", NULL, NULL, requests_write); plugin_register ("apache_bytes", NULL, NULL, bytes_write); plugin_register ("apache_scoreboard", NULL, NULL, scoreboard_write); + plugin_register ("apache_connections", NULL, NULL, connections_write); cf_register (MODULE_NAME, config, config_keys, config_keys_num); }