Fix mdstat for devices in delayed resync state

In some raid configurations resync will be delayed for devices allocated
on the same physiclal units.

Fixes #170.
This commit is contained in:
afefelov 2015-11-24 14:42:56 +05:00 committed by Tobias Schmidt
parent f261b788d2
commit 00e1db52bb
4 changed files with 12 additions and 1 deletions

View File

@ -462,6 +462,7 @@ node_md_blocks{device="md4"} 4.883648e+06
node_md_blocks{device="md6"} 1.95310144e+08 node_md_blocks{device="md6"} 1.95310144e+08
node_md_blocks{device="md7"} 7.813735424e+09 node_md_blocks{device="md7"} 7.813735424e+09
node_md_blocks{device="md8"} 1.95310144e+08 node_md_blocks{device="md8"} 1.95310144e+08
node_md_blocks{device="md9"} 523968
# HELP node_md_blocks_synced Number of blocks synced on device. # HELP node_md_blocks_synced Number of blocks synced on device.
# TYPE node_md_blocks_synced gauge # TYPE node_md_blocks_synced gauge
node_md_blocks_synced{device="md0"} 248896 node_md_blocks_synced{device="md0"} 248896
@ -471,6 +472,7 @@ node_md_blocks_synced{device="md4"} 4.883648e+06
node_md_blocks_synced{device="md6"} 1.6775552e+07 node_md_blocks_synced{device="md6"} 1.6775552e+07
node_md_blocks_synced{device="md7"} 7.813735424e+09 node_md_blocks_synced{device="md7"} 7.813735424e+09
node_md_blocks_synced{device="md8"} 1.6775552e+07 node_md_blocks_synced{device="md8"} 1.6775552e+07
node_md_blocks_synced{device="md9"} 523968
# HELP node_md_disks Total number of disks of device. # HELP node_md_disks Total number of disks of device.
# TYPE node_md_disks gauge # TYPE node_md_disks gauge
node_md_disks{device="md0"} 2 node_md_disks{device="md0"} 2
@ -480,6 +482,7 @@ node_md_disks{device="md4"} 2
node_md_disks{device="md6"} 2 node_md_disks{device="md6"} 2
node_md_disks{device="md7"} 4 node_md_disks{device="md7"} 4
node_md_disks{device="md8"} 2 node_md_disks{device="md8"} 2
node_md_disks{device="md9"} 4
# HELP node_md_disks_active Number of active disks of device. # HELP node_md_disks_active Number of active disks of device.
# TYPE node_md_disks_active gauge # TYPE node_md_disks_active gauge
node_md_disks_active{device="md0"} 2 node_md_disks_active{device="md0"} 2
@ -489,6 +492,7 @@ node_md_disks_active{device="md4"} 2
node_md_disks_active{device="md6"} 1 node_md_disks_active{device="md6"} 1
node_md_disks_active{device="md7"} 3 node_md_disks_active{device="md7"} 3
node_md_disks_active{device="md8"} 2 node_md_disks_active{device="md8"} 2
node_md_disks_active{device="md9"} 4
# HELP node_md_is_active Indicator whether the md-device is active or not. # HELP node_md_is_active Indicator whether the md-device is active or not.
# TYPE node_md_is_active gauge # TYPE node_md_is_active gauge
node_md_is_active{device="md0"} 1 node_md_is_active{device="md0"} 1
@ -498,6 +502,7 @@ node_md_is_active{device="md4"} 0
node_md_is_active{device="md6"} 1 node_md_is_active{device="md6"} 1
node_md_is_active{device="md7"} 1 node_md_is_active{device="md7"} 1
node_md_is_active{device="md8"} 1 node_md_is_active{device="md8"} 1
node_md_is_active{device="md9"} 1
# HELP node_megacli_drive_count megacli: drive error and event counters # HELP node_megacli_drive_count megacli: drive error and event counters
# TYPE node_megacli_drive_count counter # TYPE node_megacli_drive_count counter
node_megacli_drive_count{enclosure="32",slot="0",type="Media Error Count"} 0 node_megacli_drive_count{enclosure="32",slot="0",type="Media Error Count"} 0

View File

@ -23,4 +23,9 @@ md7 : active raid6 sdb1[0] sde1[3] sdd1[2] sdc1[1]
7813735424 blocks super 1.2 level 6, 512k chunk, algorithm 2 [4/3] [U_UU] 7813735424 blocks super 1.2 level 6, 512k chunk, algorithm 2 [4/3] [U_UU]
bitmap: 0/30 pages [0KB], 65536KB chunk bitmap: 0/30 pages [0KB], 65536KB chunk
md9 : active raid1 sdc2[2] sdd2[3] sdb2[1] sda2[0]
523968 blocks super 1.2 [4/4] [UUUU]
resync=DELAYED
unused devices: <none> unused devices: <none>

View File

@ -162,7 +162,7 @@ func parseMdstat(mdStatusFilePath string) ([]mdStatus, error) {
// If device is syncing at the moment, get the number of currently synced bytes, // If device is syncing at the moment, get the number of currently synced bytes,
// otherwise that number equals the size of the device. // otherwise that number equals the size of the device.
if strings.Contains(lines[j], "recovery") || strings.Contains(lines[j], "resync") { if strings.Contains(lines[j], "recovery") || strings.Contains(lines[j], "resync") && ! strings.Contains(lines[j], "resync=DELAYED") {
syncedBlocks, err = evalBuildline(lines[j]) syncedBlocks, err = evalBuildline(lines[j])
if err != nil { if err != nil {
return mdStates, fmt.Errorf("error parsing mdstat: %s", err) return mdStates, fmt.Errorf("error parsing mdstat: %s", err)

View File

@ -32,6 +32,7 @@ func TestMdadm(t *testing.T) {
"md6": {"md6", true, 1, 2, 195310144, 16775552}, "md6": {"md6", true, 1, 2, 195310144, 16775552},
"md8": {"md8", true, 2, 2, 195310144, 16775552}, "md8": {"md8", true, 2, 2, 195310144, 16775552},
"md7": {"md7", true, 3, 4, 7813735424, 7813735424}, "md7": {"md7", true, 3, 4, 7813735424, 7813735424},
"md9": {"md9", true, 4, 4, 523968, 523968},
} }
for _, md := range mdStates { for _, md := range mdStates {