From: Florian Forster Date: Mon, 20 Apr 2009 18:41:55 +0000 (+0200) Subject: Merge branch 'master' into ag/apache X-Git-Tag: collectd-4.7.0~38^2~3 X-Git-Url: https://git.octo.it/?a=commitdiff_plain;h=a3da854628383819439f0680acd2786fd00744fe;p=collectd.git Merge branch 'master' into ag/apache Conflicts: src/apache.c --- a3da854628383819439f0680acd2786fd00744fe diff --cc src/apache.c index 090ece7e,46622721..c11f55d8 --- a/src/apache.c +++ b/src/apache.c @@@ -417,30 -447,14 +453,14 @@@ static void submit_counter (const char } /* void submit_counter */ static void submit_gauge (const char *type, const char *type_instance, - gauge_t value, apache_t *st) + gauge_t g, apache_t *st) { - value_t values[1]; - value_list_t vl = VALUE_LIST_INIT; - - values[0].gauge = value; - - vl.values = values; - vl.values_len = 1; - sstrncpy (vl.host, st->host, sizeof (vl.host)); - sstrncpy (vl.plugin, "apache", sizeof (vl.plugin)); - sstrncpy (vl.plugin_instance, "", sizeof (vl.plugin_instance)); - sstrncpy (vl.type, type, sizeof (vl.type)); - - if (type_instance != NULL) - sstrncpy (vl.type_instance, type_instance, - sizeof (vl.type_instance)); - - set_plugin_instance (st, &vl); - - plugin_dispatch_values (&vl); - } /* void submit_counter */ + value_t v; + v.gauge = g; + submit_value (type, type_instance, v, st); + } /* void submit_gauge */ -static void submit_scoreboard (char *buf, apache_t *st) +static void submit_scoreboard (char *buf, int server, apache_t *st) { /* * Scoreboard Key: @@@ -490,46 -490,22 +510,46 @@@ else if (buf[i] == 'L') logging++; else if (buf[i] == 'G') finishing++; else if (buf[i] == 'I') idle_cleanup++; + else if (buf[i] == 'r') lighttpd_read++; + else if (buf[i] == 'h') handle_request++; + else if (buf[i] == 'E') hard_error++; + else if (buf[i] == 'q') request_start++; + else if (buf[i] == 'Q') request_end++; + else if (buf[i] == 's') response_start++; + else if (buf[i] == 'S') response_end++; } - submit_gauge ("apache_scoreboard", "open" , open, st); - submit_gauge ("apache_scoreboard", "waiting" , waiting, st); - submit_gauge ("apache_scoreboard", "starting" , starting, st); - submit_gauge ("apache_scoreboard", "reading" , reading, st); - submit_gauge ("apache_scoreboard", "sending" , sending, st); - submit_gauge ("apache_scoreboard", "keepalive", keepalive, st); - submit_gauge ("apache_scoreboard", "dnslookup", dnslookup, st); - submit_gauge ("apache_scoreboard", "closing" , closing, st); - submit_gauge ("apache_scoreboard", "logging" , logging, st); - submit_gauge ("apache_scoreboard", "finishing", finishing, st); - submit_gauge ("apache_scoreboard", "idle_cleanup", idle_cleanup, st); + if (server == APACHE) + { + submit_gauge ("apache_scoreboard", "open" , open, st); + submit_gauge ("apache_scoreboard", "waiting" , waiting, st); + submit_gauge ("apache_scoreboard", "starting" , starting, st); + submit_gauge ("apache_scoreboard", "reading" , reading, st); + submit_gauge ("apache_scoreboard", "sending" , sending, st); + submit_gauge ("apache_scoreboard", "keepalive", keepalive, st); + submit_gauge ("apache_scoreboard", "dnslookup", dnslookup, st); + submit_gauge ("apache_scoreboard", "closing" , closing, st); + submit_gauge ("apache_scoreboard", "logging" , logging, st); + submit_gauge ("apache_scoreboard", "finishing", finishing, st); + submit_gauge ("apache_scoreboard", "idle_cleanup", idle_cleanup, st); + } else + { + submit_gauge ("apache_scoreboard", "connect" , open, st); + submit_gauge ("apache_scoreboard", "close" , closing, st); + submit_gauge ("apache_scoreboard", "hard_error" , hard_error, st); + submit_gauge ("apache_scoreboard", "read" , lighttpd_read, st); + submit_gauge ("apache_scoreboard", "read_post" , reading, st); + submit_gauge ("apache_scoreboard", "write" , sending, st); + submit_gauge ("apache_scoreboard", "handle_request", handle_request, st); + submit_gauge ("apache_scoreboard", "request_start" , request_start, st); + submit_gauge ("apache_scoreboard", "request_end" , request_end, st); + submit_gauge ("apache_scoreboard", "response_start", response_start, st); + submit_gauge ("apache_scoreboard", "response_end" , response_end, st); + + } } - static int apache_read_host (apache_t *st) + static int apache_read_host (user_data_t *user_data) /* {{{ */ { int i; @@@ -540,12 -516,23 +560,24 @@@ char *fields[4]; int fields_num; + int server = LIGHTTPD; /* default is lighttpd */ + apache_t *st; + + st = user_data->data; + + assert (st->url != NULL); + /* (Assured by `config_add') */ + if (st->curl == NULL) - return (-1); - if (st->url == NULL) - return (-1); + { + int status; + + status = init_host (st); + if (status != 0) + return (-1); + } + assert (st->curl != NULL); st->apache_buffer_fill = 0; if (curl_easy_perform (st->curl) != 0)