Code

drbd plugin: improve header lines identification
authorMarc Fournier <marc.fournier@camptocamp.com>
Wed, 20 Jan 2016 21:32:03 +0000 (22:32 +0100)
committerFlorian Forster <octo@collectd.org>
Fri, 22 Jan 2016 09:51:17 +0000 (10:51 +0100)
Recent DRBD versions display more detailed build information in
`/proc/drbd`, which caused the header identification to fail.

Comparing the first part of each line against all known header prefixes
will hopefully make this more robust.

Fixes #1514

Signed-off-by: Florian Forster <octo@collectd.org>
src/drbd.c

index cc306dcb2be679e7c91fde0255c3793033a1e232..d46bb020ed5cc89d821c1ea5caa71d665f169ec8 100644 (file)
@@ -142,8 +142,12 @@ static int drbd_read (void)
                                fields, STATIC_ARRAY_SIZE (fields));
 
                /* ignore headers (first two iterations) */
-               if (fields_num < 4)
+               if ((strcmp(fields[0], "version:") == 0) ||
+                               (strcmp(fields[0], "srcversion:") == 0) ||
+                               (strcmp(fields[0], "GIT-hash:") == 0))
+               {
                        continue;
+               }
 
                if (isdigit(fields[0][0]))
                {