Skip to content

Commit 1f6b5ae

Browse files
committed
#219 - add fixes for @samzhang111 super token
1 parent 8d756ca commit 1f6b5ae

File tree

4 files changed

+15
-4
lines changed

4 files changed

+15
-4
lines changed

collector/fixtures/e2e-output.txt

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -713,6 +713,7 @@ node_load5 0.37
713713
# HELP node_md_blocks Total number of blocks on device.
714714
# TYPE node_md_blocks gauge
715715
node_md_blocks{device="md0"} 248896
716+
node_md_blocks{device="md00"} 4.186624e+06
716717
node_md_blocks{device="md10"} 3.14159265e+08
717718
node_md_blocks{device="md11"} 4.190208e+06
718719
node_md_blocks{device="md12"} 3.886394368e+09
@@ -727,6 +728,7 @@ node_md_blocks{device="md9"} 523968
727728
# HELP node_md_blocks_synced Number of blocks synced on device.
728729
# TYPE node_md_blocks_synced gauge
729730
node_md_blocks_synced{device="md0"} 248896
731+
node_md_blocks_synced{device="md00"} 4.186624e+06
730732
node_md_blocks_synced{device="md10"} 3.14159265e+08
731733
node_md_blocks_synced{device="md11"} 4.190208e+06
732734
node_md_blocks_synced{device="md12"} 3.886394368e+09
@@ -741,6 +743,7 @@ node_md_blocks_synced{device="md9"} 523968
741743
# HELP node_md_disks Total number of disks of device.
742744
# TYPE node_md_disks gauge
743745
node_md_disks{device="md0"} 2
746+
node_md_disks{device="md00"} 1
744747
node_md_disks{device="md10"} 2
745748
node_md_disks{device="md11"} 2
746749
node_md_disks{device="md12"} 2
@@ -755,6 +758,7 @@ node_md_disks{device="md9"} 4
755758
# HELP node_md_disks_active Number of active disks of device.
756759
# TYPE node_md_disks_active gauge
757760
node_md_disks_active{device="md0"} 2
761+
node_md_disks_active{device="md00"} 1
758762
node_md_disks_active{device="md10"} 2
759763
node_md_disks_active{device="md11"} 2
760764
node_md_disks_active{device="md12"} 2
@@ -769,6 +773,7 @@ node_md_disks_active{device="md9"} 4
769773
# HELP node_md_is_active Indicator whether the md-device is active or not.
770774
# TYPE node_md_is_active gauge
771775
node_md_is_active{device="md0"} 1
776+
node_md_is_active{device="md00"} 1
772777
node_md_is_active{device="md10"} 1
773778
node_md_is_active{device="md11"} 1
774779
node_md_is_active{device="md12"} 1

collector/fixtures/proc/mdstat

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,4 +40,7 @@ md12 : active raid0 sdc2[0] sdd2[1]
4040
md219 : inactive sdb[2](S) sdc[1](S) sda[0](S)
4141
7932 blocks super external:imsm
4242

43+
md00 : active raid0 xvdb[0]
44+
4186624 blocks super 1.2 256k chunks
45+
4346
unused devices: <none>

collector/mdadm_linux.go

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -28,9 +28,9 @@ import (
2828
)
2929

3030
var (
31-
statuslineRE = regexp.MustCompile(`(\d+) blocks .*\[(\d+)/(\d+)\] \[[U_]+\]`)
32-
raid0lineRE = regexp.MustCompile(`(\d+) blocks .*\d+k chunks`)
33-
buildlineRE = regexp.MustCompile(`\((\d+)/\d+\)`)
31+
statuslineRE = regexp.MustCompile(`(\d+) blocks .*\[(\d+)/(\d+)\] \[[U_]+\]`)
32+
raid0lineRE = regexp.MustCompile(`(\d+) blocks( super ([0-9\.])*)? \d+k chunks`)
33+
buildlineRE = regexp.MustCompile(`\((\d+)/\d+\)`)
3434
unknownPersonalityLine = regexp.MustCompile(`(\d+) blocks (.*)`)
3535
raidPersonalityRE = regexp.MustCompile(`raid[0-9]+`)
3636
)
@@ -82,7 +82,7 @@ func evalStatusline(statusline string) (active, total, size int64, err error) {
8282
func evalRaid0line(statusline string) (size int64, err error) {
8383
matches := raid0lineRE.FindStringSubmatch(statusline)
8484

85-
if len(matches) != 2 {
85+
if len(matches) < 2 {
8686
return 0, fmt.Errorf("invalid raid0 status line: %s", statusline)
8787
}
8888

@@ -179,6 +179,7 @@ func parseMdstat(mdStatusFilePath string) ([]mdStatus, error) {
179179
for _, possiblePersonality := range mainLine {
180180
if raidPersonalityRE.MatchString(possiblePersonality) {
181181
personality = possiblePersonality
182+
// break
182183
}
183184
}
184185

collector/mdadm_linux_test.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ func TestMdadm(t *testing.T) {
2525
}
2626

2727
refs := map[string]mdStatus{
28+
// { "<name>", <active?>, <numDisksActive>, <totalNumDisks>, <amountSynced>, <totalSize>}
2829
"md3": {"md3", true, 8, 8, 5853468288, 5853468288},
2930
"md127": {"md127", true, 2, 2, 312319552, 312319552},
3031
"md0": {"md0", true, 2, 2, 248896, 248896},
@@ -37,6 +38,7 @@ func TestMdadm(t *testing.T) {
3738
"md11": {"md11", true, 2, 2, 4190208, 4190208},
3839
"md12": {"md12", true, 2, 2, 3886394368, 3886394368},
3940
"md219": {"md219", false, 2, 2, 7932, 7932},
41+
"md00": {"md00", true, 1, 1, 4186624, 4186624},
4042
}
4143

4244
for _, md := range mdStates {

0 commit comments

Comments
 (0)