From afac1f7433ed50e640fd87a3f1be659271956618 Mon Sep 17 00:00:00 2001
From: Ben Kochie <superq@gmail.com>
Date: Mon, 19 Sep 2016 10:28:06 +0200
Subject: [PATCH] Update mdstat fixture based on linux source.

Update `Contains` matching for `resync=`
---
 collector/fixtures/proc/mdstat | 4 ++--
 collector/mdadm_linux.go       | 4 +++-
 2 files changed, 5 insertions(+), 3 deletions(-)

diff --git a/collector/fixtures/proc/mdstat b/collector/fixtures/proc/mdstat
index de5f121e..1021ffc2 100644
--- a/collector/fixtures/proc/mdstat
+++ b/collector/fixtures/proc/mdstat
@@ -25,13 +25,13 @@ md7 : active raid6 sdb1[0] sde1[3] sdd1[2] sdc1[1]
 
 md9 : active raid1 sdc2[2] sdd2[3] sdb2[1] sda2[0]
       523968 blocks super 1.2 [4/4] [UUUU]
-            resync=DELAYED
+	resync=DELAYED
 
 md10 : active raid0 sda1[0] sdb1[1]
       314159265 blocks 64k chunks
 
 md11 : active (auto-read-only) raid1 sdb2[0] sdc2[1]
       4190208 blocks super 1.2 [2/2] [UU]
-        resync=PENDING
+	resync=PENDING
 
 unused devices: <none>
diff --git a/collector/mdadm_linux.go b/collector/mdadm_linux.go
index 537d16fa..3e5ed6d8 100644
--- a/collector/mdadm_linux.go
+++ b/collector/mdadm_linux.go
@@ -190,7 +190,9 @@ func parseMdstat(mdStatusFilePath string) ([]mdStatus, error) {
 
 		// If device is syncing at the moment, get the number of currently synced bytes,
 		// otherwise that number equals the size of the device.
-		if strings.Contains(lines[j], "recovery") || strings.Contains(lines[j], "resync") && !strings.Contains(lines[j], "resync=DELAYED") && !strings.Contains(lines[j], "resync=PENDING") {
+		if strings.Contains(lines[j], "recovery") ||
+			strings.Contains(lines[j], "resync") &&
+				!strings.Contains(lines[j], "\tresync=") {
 			syncedBlocks, err = evalBuildline(lines[j])
 			if err != nil {
 				return mdStates, fmt.Errorf("error parsing mdstat: %s", err)