Merge branch 'master' into ag/apache
authorFlorian Forster <octo@leeloo.lan.home.verplant.org>
Mon, 20 Apr 2009 18:41:55 +0000 (20:41 +0200)
committerFlorian Forster <octo@leeloo.lan.home.verplant.org>
Mon, 20 Apr 2009 18:41:55 +0000 (20:41 +0200)
Conflicts:
src/apache.c

1  2 
src/apache.c

diff --cc 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:
                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;
  
  
        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)