From 6a4e409854a5322bed28347237a7614c59925e2a Mon Sep 17 00:00:00 2001 From: Florian Forster Date: Wed, 12 Oct 2016 16:56:58 +0200 Subject: [PATCH] nginx plugin: Add comment, fix indentation. Add a comment reminding us to remove the "handled" metric in a later major release. Also fixes mixes tab/space indenting. --- src/nginx.c | 33 ++++++++++++++++++--------------- 1 file changed, 18 insertions(+), 15 deletions(-) diff --git a/src/nginx.c b/src/nginx.c index c03c67ea..08c24f9a 100644 --- a/src/nginx.c +++ b/src/nginx.c @@ -139,7 +139,7 @@ static int init (void) #else static char credentials[1024]; int status = ssnprintf (credentials, sizeof (credentials), - "%s:%s", user, pass == NULL ? "" : pass); + "%s:%s", user, pass == NULL ? "" : pass); if ((status < 0) || ((size_t) status >= sizeof (credentials))) { ERROR ("nginx plugin: Credentials would have been truncated."); @@ -262,34 +262,37 @@ static int nginx_read (void) for (int i = 0; i < lines_num; i++) { fields_num = strsplit (lines[i], fields, - (sizeof (fields) / sizeof (fields[0]))); + (sizeof (fields) / sizeof (fields[0]))); if (fields_num == 3) { if ((strcmp (fields[0], "Active") == 0) - && (strcmp (fields[1], "connections:") == 0)) + && (strcmp (fields[1], "connections:") == 0)) { - submit ("nginx_connections", "active", atoll (fields[2])); + submit ("nginx_connections", "active", atoll (fields[2])); } else if ((atoll (fields[0]) != 0) - && (atoll (fields[1]) != 0) - && (atoll (fields[2]) != 0)) + && (atoll (fields[1]) != 0) + && (atoll (fields[2]) != 0)) { - submit ("connections", "accepted", atoll (fields[0])); - submit ("connections", "handled", atoll (fields[1])); - submit ("connections", "failed", (atoll(fields[0]) - atoll (fields[1]))); - submit ("nginx_requests", NULL, atoll (fields[2])); + 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) { if ((strcmp (fields[0], "Reading:") == 0) - && (strcmp (fields[2], "Writing:") == 0) - && (strcmp (fields[4], "Waiting:") == 0)) + && (strcmp (fields[2], "Writing:") == 0) + && (strcmp (fields[4], "Waiting:") == 0)) { - submit ("nginx_connections", "reading", atoll (fields[1])); - submit ("nginx_connections", "writing", atoll (fields[3])); - submit ("nginx_connections", "waiting", atoll (fields[5])); + submit ("nginx_connections", "reading", atoll (fields[1])); + submit ("nginx_connections", "writing", atoll (fields[3])); + submit ("nginx_connections", "waiting", atoll (fields[5])); } } } -- 2.30.2