From: Florian Forster Date: Fri, 20 Nov 2015 10:01:38 +0000 (+0100) Subject: apache plugin: DRY: use macro to determine number of fields. X-Git-Tag: collectd-5.5.1~48^2~3 X-Git-Url: https://git.tokkee.org/?a=commitdiff_plain;h=c68a61a08267319ebfeddd372ab16124c592b288;p=collectd.git apache plugin: DRY: use macro to determine number of fields. --- diff --git a/src/apache.c b/src/apache.c index 864dfcf8..13c8db66 100644 --- a/src/apache.c +++ b/src/apache.c @@ -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) {