Skip to content

Commit bb2b984

Browse files
authored
Merge pull request #341 from EdSchouten/mdadm-attributes
mdstat: Fix parsing of RAID0 lines that contain additional attributes.
2 parents 38ca73e + 9749c2c commit bb2b984

File tree

4 files changed

+10
-1
lines changed

4 files changed

+10
-1
lines changed

collector/fixtures/e2e-output.txt

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -715,6 +715,7 @@ node_load5 0.37
715715
node_md_blocks{device="md0"} 248896
716716
node_md_blocks{device="md10"} 3.14159265e+08
717717
node_md_blocks{device="md11"} 4.190208e+06
718+
node_md_blocks{device="md12"} 3.886394368e+09
718719
node_md_blocks{device="md127"} 3.12319552e+08
719720
node_md_blocks{device="md3"} 5.853468288e+09
720721
node_md_blocks{device="md4"} 4.883648e+06
@@ -727,6 +728,7 @@ node_md_blocks{device="md9"} 523968
727728
node_md_blocks_synced{device="md0"} 248896
728729
node_md_blocks_synced{device="md10"} 3.14159265e+08
729730
node_md_blocks_synced{device="md11"} 4.190208e+06
731+
node_md_blocks_synced{device="md12"} 3.886394368e+09
730732
node_md_blocks_synced{device="md127"} 3.12319552e+08
731733
node_md_blocks_synced{device="md3"} 5.853468288e+09
732734
node_md_blocks_synced{device="md4"} 4.883648e+06
@@ -739,6 +741,7 @@ node_md_blocks_synced{device="md9"} 523968
739741
node_md_disks{device="md0"} 2
740742
node_md_disks{device="md10"} 2
741743
node_md_disks{device="md11"} 2
744+
node_md_disks{device="md12"} 2
742745
node_md_disks{device="md127"} 2
743746
node_md_disks{device="md3"} 8
744747
node_md_disks{device="md4"} 2
@@ -751,6 +754,7 @@ node_md_disks{device="md9"} 4
751754
node_md_disks_active{device="md0"} 2
752755
node_md_disks_active{device="md10"} 2
753756
node_md_disks_active{device="md11"} 2
757+
node_md_disks_active{device="md12"} 2
754758
node_md_disks_active{device="md127"} 2
755759
node_md_disks_active{device="md3"} 8
756760
node_md_disks_active{device="md4"} 2
@@ -763,6 +767,7 @@ node_md_disks_active{device="md9"} 4
763767
node_md_is_active{device="md0"} 1
764768
node_md_is_active{device="md10"} 1
765769
node_md_is_active{device="md11"} 1
770+
node_md_is_active{device="md12"} 1
766771
node_md_is_active{device="md127"} 1
767772
node_md_is_active{device="md3"} 1
768773
node_md_is_active{device="md4"} 0

collector/fixtures/proc/mdstat

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,4 +34,7 @@ md11 : active (auto-read-only) raid1 sdb2[0] sdc2[1]
3434
4190208 blocks super 1.2 [2/2] [UU]
3535
resync=PENDING
3636

37+
md12 : active raid0 sdc2[0] sdd2[1]
38+
3886394368 blocks super 1.2 512k chunks
39+
3740
unused devices: <none>

collector/mdadm_linux.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ import (
2929

3030
var (
3131
statuslineRE = regexp.MustCompile(`(\d+) blocks .*\[(\d+)/(\d+)\] \[[U_]+\]`)
32-
raid0lineRE = regexp.MustCompile(`(\d+) blocks \d+k chunks`)
32+
raid0lineRE = regexp.MustCompile(`(\d+) blocks .*\d+k chunks`)
3333
buildlineRE = regexp.MustCompile(`\((\d+)/\d+\)`)
3434
)
3535

collector/mdadm_linux_test.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ func TestMdadm(t *testing.T) {
3535
"md9": {"md9", true, 4, 4, 523968, 523968},
3636
"md10": {"md10", true, 2, 2, 314159265, 314159265},
3737
"md11": {"md11", true, 2, 2, 4190208, 4190208},
38+
"md12": {"md12", true, 2, 2, 3886394368, 3886394368},
3839
}
3940

4041
for _, md := range mdStates {

0 commit comments

Comments
 (0)