X-Git-Url: https://git.octo.it/?a=blobdiff_plain;f=src%2Fnginx.c;h=060eae23b1712c79f09ecc43fd29d7208a590289;hb=ca89ee257db233a0512c73b6d8353b1aa86e3e8a;hp=fc935b4aa7c3bdf44a221a582af9a27ad2a09634;hpb=79963d13c1884d1d92667cc502ad20758b084a12;p=collectd.git diff --git a/src/nginx.c b/src/nginx.c index fc935b4a..060eae23 100644 --- a/src/nginx.c +++ b/src/nginx.c @@ -133,10 +133,6 @@ static int init(void) { #endif } - if (url != NULL) { - curl_easy_setopt(curl, CURLOPT_URL, url); - } - curl_easy_setopt(curl, CURLOPT_FOLLOWLOCATION, 1L); curl_easy_setopt(curl, CURLOPT_MAXREDIRS, 50L); @@ -182,10 +178,8 @@ static void submit(const char *type, const char *inst, long long value) { return; vl.values = values; - vl.values_len = 1; - sstrncpy(vl.host, hostname_g, sizeof(vl.host)); + vl.values_len = STATIC_ARRAY_SIZE(values); sstrncpy(vl.plugin, "nginx", sizeof(vl.plugin)); - sstrncpy(vl.plugin_instance, "", sizeof(vl.plugin_instance)); sstrncpy(vl.type, type, sizeof(vl.type)); if (inst != NULL) @@ -209,6 +203,9 @@ static int nginx_read(void) { return (-1); nginx_buffer_len = 0; + + curl_easy_setopt(curl, CURLOPT_URL, url); + if (curl_easy_perform(curl) != CURLE_OK) { WARNING("nginx plugin: curl_easy_perform failed: %s", nginx_curl_error); return (-1); @@ -227,7 +224,7 @@ static int nginx_read(void) { /* * Active connections: 291 * server accepts handled requests - * 16630948 16630948 31070465 + * 101059015 100422216 347910649 * Reading: 6 Writing: 179 Waiting: 106 */ for (int i = 0; i < lines_num; i++) { @@ -241,7 +238,11 @@ static int nginx_read(void) { } else if ((atoll(fields[0]) != 0) && (atoll(fields[1]) != 0) && (atoll(fields[2]) != 0)) { submit("connections", "accepted", atoll(fields[0])); + /* TODO: The legacy metric "handled", which is the sum of "accepted" and + * "failed", is reported for backwards compatibility only. Remove in the + * next major version. */ submit("connections", "handled", atoll(fields[1])); + submit("connections", "failed", (atoll(fields[0]) - atoll(fields[1]))); submit("nginx_requests", NULL, atoll(fields[2])); } } else if (fields_num == 6) {