From 9749c2c0b3905498dfa4ed3ef869134fc5edf39c Mon Sep 17 00:00:00 2001 From: Ed Schouten Date: Mon, 14 Nov 2016 14:30:33 +0100 Subject: [PATCH] mdstat: Fix parsing of RAID0 lines that contain additional attributes. We seem to have a small number of Linux servers here that have lines in /proc/mdstat that cannot be parsed by the node exporter, due to them containing attributes that are not matched by the regular expression ("super 1.2"). Extend the regular expression to skip this data, just like we do for all of the other status lines. --- collector/fixtures/e2e-output.txt | 5 +++++ collector/fixtures/proc/mdstat | 3 +++ collector/mdadm_linux.go | 2 +- collector/mdadm_linux_test.go | 1 + 4 files changed, 10 insertions(+), 1 deletion(-) diff --git a/collector/fixtures/e2e-output.txt b/collector/fixtures/e2e-output.txt index 20ea1dcd..4288a10c 100644 --- a/collector/fixtures/e2e-output.txt +++ b/collector/fixtures/e2e-output.txt @@ -715,6 +715,7 @@ node_load5 0.37 node_md_blocks{device="md0"} 248896 node_md_blocks{device="md10"} 3.14159265e+08 node_md_blocks{device="md11"} 4.190208e+06 +node_md_blocks{device="md12"} 3.886394368e+09 node_md_blocks{device="md127"} 3.12319552e+08 node_md_blocks{device="md3"} 5.853468288e+09 node_md_blocks{device="md4"} 4.883648e+06 @@ -727,6 +728,7 @@ node_md_blocks{device="md9"} 523968 node_md_blocks_synced{device="md0"} 248896 node_md_blocks_synced{device="md10"} 3.14159265e+08 node_md_blocks_synced{device="md11"} 4.190208e+06 +node_md_blocks_synced{device="md12"} 3.886394368e+09 node_md_blocks_synced{device="md127"} 3.12319552e+08 node_md_blocks_synced{device="md3"} 5.853468288e+09 node_md_blocks_synced{device="md4"} 4.883648e+06 @@ -739,6 +741,7 @@ node_md_blocks_synced{device="md9"} 523968 node_md_disks{device="md0"} 2 node_md_disks{device="md10"} 2 node_md_disks{device="md11"} 2 +node_md_disks{device="md12"} 2 node_md_disks{device="md127"} 2 node_md_disks{device="md3"} 8 node_md_disks{device="md4"} 2 @@ -751,6 +754,7 @@ node_md_disks{device="md9"} 4 node_md_disks_active{device="md0"} 2 node_md_disks_active{device="md10"} 2 node_md_disks_active{device="md11"} 2 +node_md_disks_active{device="md12"} 2 node_md_disks_active{device="md127"} 2 node_md_disks_active{device="md3"} 8 node_md_disks_active{device="md4"} 2 @@ -763,6 +767,7 @@ node_md_disks_active{device="md9"} 4 node_md_is_active{device="md0"} 1 node_md_is_active{device="md10"} 1 node_md_is_active{device="md11"} 1 +node_md_is_active{device="md12"} 1 node_md_is_active{device="md127"} 1 node_md_is_active{device="md3"} 1 node_md_is_active{device="md4"} 0 diff --git a/collector/fixtures/proc/mdstat b/collector/fixtures/proc/mdstat index 1021ffc2..5a397fce 100644 --- a/collector/fixtures/proc/mdstat +++ b/collector/fixtures/proc/mdstat @@ -34,4 +34,7 @@ md11 : active (auto-read-only) raid1 sdb2[0] sdc2[1] 4190208 blocks super 1.2 [2/2] [UU] resync=PENDING +md12 : active raid0 sdc2[0] sdd2[1] + 3886394368 blocks super 1.2 512k chunks + unused devices: diff --git a/collector/mdadm_linux.go b/collector/mdadm_linux.go index 3e5ed6d8..61d9ebdb 100644 --- a/collector/mdadm_linux.go +++ b/collector/mdadm_linux.go @@ -29,7 +29,7 @@ import ( var ( statuslineRE = regexp.MustCompile(`(\d+) blocks .*\[(\d+)/(\d+)\] \[[U_]+\]`) - raid0lineRE = regexp.MustCompile(`(\d+) blocks \d+k chunks`) + raid0lineRE = regexp.MustCompile(`(\d+) blocks .*\d+k chunks`) buildlineRE = regexp.MustCompile(`\((\d+)/\d+\)`) ) diff --git a/collector/mdadm_linux_test.go b/collector/mdadm_linux_test.go index 9289576f..89456042 100644 --- a/collector/mdadm_linux_test.go +++ b/collector/mdadm_linux_test.go @@ -35,6 +35,7 @@ func TestMdadm(t *testing.T) { "md9": {"md9", true, 4, 4, 523968, 523968}, "md10": {"md10", true, 2, 2, 314159265, 314159265}, "md11": {"md11", true, 2, 2, 4190208, 4190208}, + "md12": {"md12", true, 2, 2, 3886394368, 3886394368}, } for _, md := range mdStates {