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.
This commit is contained in:
Ed Schouten 2016-11-14 14:30:33 +01:00
parent 38ca73e783
commit 9749c2c0b3
4 changed files with 10 additions and 1 deletions

View File

@ -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

View File

@ -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: <none>

View File

@ -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+\)`)
)

View File

@ -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 {