Code

apache plugin: DRY: use macro to determine number of fields.
authorFlorian Forster <octo@collectd.org>
Fri, 20 Nov 2015 10:01:38 +0000 (11:01 +0100)
committerFlorian Forster <octo@collectd.org>
Fri, 20 Nov 2015 10:01:38 +0000 (11:01 +0100)
src/apache.c

index 864dfcf84256bb84facb7fee1f0560f39cf83fca..13c8db66801291fb05cac46171ce089e14175e47 100644 (file)
@@ -630,18 +630,14 @@ static int apache_read_host (user_data_t *user_data) /* {{{ */
        while ((line = strtok_r (ptr, "\n\r", &saveptr)) != NULL)
        {
                ptr = NULL;
-               fields_num = strsplit (line, fields, 4);
+               fields_num = strsplit (line, fields, STATIC_ARRAY_SIZE (fields));
 
                if (fields_num == 3)
                {
-                       if ((strcmp (fields[0], "Total") == 0)
-                                       && (strcmp (fields[1], "Accesses:") == 0))
-                               submit_derive ("apache_requests", "",
-                                               atoll (fields[2]), st);
-                       else if ((strcmp (fields[0], "Total") == 0)
-                                       && (strcmp (fields[1], "kBytes:") == 0))
-                               submit_derive ("apache_bytes", "",
-                                               1024LL * atoll (fields[2]), st);
+                       if ((strcmp (fields[0], "Total") == 0) && (strcmp (fields[1], "Accesses:") == 0))
+                               submit_derive ("apache_requests", "", atoll (fields[2]), st);
+                       else if ((strcmp (fields[0], "Total") == 0) && (strcmp (fields[1], "kBytes:") == 0))
+                               submit_derive ("apache_bytes", "", 1024LL * atoll (fields[2]), st);
                }
                else if (fields_num == 2)
                {