mirror of
https://github.com/prometheus/node_exporter.git
synced 2024-11-09 23:24:09 -08:00
Fix mdadm collector issues (#985)
* Send "Personality unknown" to debug, not info, remove unnecessary newline. * Add support for "linear" personality. * Always set number of active disks to 0 when a device is inactive. * Add total disks calculation to unknown personalites. Signed-off-by: Ben Kochie <superq@gmail.com>
This commit is contained in:
parent
55c32fcf02
commit
107e5dfecc
|
@ -1022,6 +1022,7 @@ node_md_blocks{device="md00"} 4.186624e+06
|
||||||
node_md_blocks{device="md10"} 3.14159265e+08
|
node_md_blocks{device="md10"} 3.14159265e+08
|
||||||
node_md_blocks{device="md11"} 4.190208e+06
|
node_md_blocks{device="md11"} 4.190208e+06
|
||||||
node_md_blocks{device="md12"} 3.886394368e+09
|
node_md_blocks{device="md12"} 3.886394368e+09
|
||||||
|
node_md_blocks{device="md120"} 2.095104e+06
|
||||||
node_md_blocks{device="md126"} 1.855870976e+09
|
node_md_blocks{device="md126"} 1.855870976e+09
|
||||||
node_md_blocks{device="md127"} 3.12319552e+08
|
node_md_blocks{device="md127"} 3.12319552e+08
|
||||||
node_md_blocks{device="md219"} 7932
|
node_md_blocks{device="md219"} 7932
|
||||||
|
@ -1038,6 +1039,7 @@ node_md_blocks_synced{device="md00"} 4.186624e+06
|
||||||
node_md_blocks_synced{device="md10"} 3.14159265e+08
|
node_md_blocks_synced{device="md10"} 3.14159265e+08
|
||||||
node_md_blocks_synced{device="md11"} 4.190208e+06
|
node_md_blocks_synced{device="md11"} 4.190208e+06
|
||||||
node_md_blocks_synced{device="md12"} 3.886394368e+09
|
node_md_blocks_synced{device="md12"} 3.886394368e+09
|
||||||
|
node_md_blocks_synced{device="md120"} 2.095104e+06
|
||||||
node_md_blocks_synced{device="md126"} 1.855870976e+09
|
node_md_blocks_synced{device="md126"} 1.855870976e+09
|
||||||
node_md_blocks_synced{device="md127"} 3.12319552e+08
|
node_md_blocks_synced{device="md127"} 3.12319552e+08
|
||||||
node_md_blocks_synced{device="md219"} 7932
|
node_md_blocks_synced{device="md219"} 7932
|
||||||
|
@ -1054,9 +1056,10 @@ node_md_disks{device="md00"} 1
|
||||||
node_md_disks{device="md10"} 2
|
node_md_disks{device="md10"} 2
|
||||||
node_md_disks{device="md11"} 2
|
node_md_disks{device="md11"} 2
|
||||||
node_md_disks{device="md12"} 2
|
node_md_disks{device="md12"} 2
|
||||||
|
node_md_disks{device="md120"} 2
|
||||||
node_md_disks{device="md126"} 2
|
node_md_disks{device="md126"} 2
|
||||||
node_md_disks{device="md127"} 2
|
node_md_disks{device="md127"} 2
|
||||||
node_md_disks{device="md219"} 0
|
node_md_disks{device="md219"} 3
|
||||||
node_md_disks{device="md3"} 8
|
node_md_disks{device="md3"} 8
|
||||||
node_md_disks{device="md4"} 2
|
node_md_disks{device="md4"} 2
|
||||||
node_md_disks{device="md6"} 2
|
node_md_disks{device="md6"} 2
|
||||||
|
@ -1070,11 +1073,12 @@ node_md_disks_active{device="md00"} 1
|
||||||
node_md_disks_active{device="md10"} 2
|
node_md_disks_active{device="md10"} 2
|
||||||
node_md_disks_active{device="md11"} 2
|
node_md_disks_active{device="md11"} 2
|
||||||
node_md_disks_active{device="md12"} 2
|
node_md_disks_active{device="md12"} 2
|
||||||
|
node_md_disks_active{device="md120"} 2
|
||||||
node_md_disks_active{device="md126"} 2
|
node_md_disks_active{device="md126"} 2
|
||||||
node_md_disks_active{device="md127"} 2
|
node_md_disks_active{device="md127"} 2
|
||||||
node_md_disks_active{device="md219"} 0
|
node_md_disks_active{device="md219"} 0
|
||||||
node_md_disks_active{device="md3"} 8
|
node_md_disks_active{device="md3"} 8
|
||||||
node_md_disks_active{device="md4"} 2
|
node_md_disks_active{device="md4"} 0
|
||||||
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
|
||||||
|
@ -1086,6 +1090,7 @@ node_md_is_active{device="md00"} 1
|
||||||
node_md_is_active{device="md10"} 1
|
node_md_is_active{device="md10"} 1
|
||||||
node_md_is_active{device="md11"} 1
|
node_md_is_active{device="md11"} 1
|
||||||
node_md_is_active{device="md12"} 1
|
node_md_is_active{device="md12"} 1
|
||||||
|
node_md_is_active{device="md120"} 1
|
||||||
node_md_is_active{device="md126"} 1
|
node_md_is_active{device="md126"} 1
|
||||||
node_md_is_active{device="md127"} 1
|
node_md_is_active{device="md127"} 1
|
||||||
node_md_is_active{device="md219"} 0
|
node_md_is_active{device="md219"} 0
|
||||||
|
|
|
@ -1022,6 +1022,7 @@ node_md_blocks{device="md00"} 4.186624e+06
|
||||||
node_md_blocks{device="md10"} 3.14159265e+08
|
node_md_blocks{device="md10"} 3.14159265e+08
|
||||||
node_md_blocks{device="md11"} 4.190208e+06
|
node_md_blocks{device="md11"} 4.190208e+06
|
||||||
node_md_blocks{device="md12"} 3.886394368e+09
|
node_md_blocks{device="md12"} 3.886394368e+09
|
||||||
|
node_md_blocks{device="md120"} 2.095104e+06
|
||||||
node_md_blocks{device="md126"} 1.855870976e+09
|
node_md_blocks{device="md126"} 1.855870976e+09
|
||||||
node_md_blocks{device="md127"} 3.12319552e+08
|
node_md_blocks{device="md127"} 3.12319552e+08
|
||||||
node_md_blocks{device="md219"} 7932
|
node_md_blocks{device="md219"} 7932
|
||||||
|
@ -1038,6 +1039,7 @@ node_md_blocks_synced{device="md00"} 4.186624e+06
|
||||||
node_md_blocks_synced{device="md10"} 3.14159265e+08
|
node_md_blocks_synced{device="md10"} 3.14159265e+08
|
||||||
node_md_blocks_synced{device="md11"} 4.190208e+06
|
node_md_blocks_synced{device="md11"} 4.190208e+06
|
||||||
node_md_blocks_synced{device="md12"} 3.886394368e+09
|
node_md_blocks_synced{device="md12"} 3.886394368e+09
|
||||||
|
node_md_blocks_synced{device="md120"} 2.095104e+06
|
||||||
node_md_blocks_synced{device="md126"} 1.855870976e+09
|
node_md_blocks_synced{device="md126"} 1.855870976e+09
|
||||||
node_md_blocks_synced{device="md127"} 3.12319552e+08
|
node_md_blocks_synced{device="md127"} 3.12319552e+08
|
||||||
node_md_blocks_synced{device="md219"} 7932
|
node_md_blocks_synced{device="md219"} 7932
|
||||||
|
@ -1054,9 +1056,10 @@ node_md_disks{device="md00"} 1
|
||||||
node_md_disks{device="md10"} 2
|
node_md_disks{device="md10"} 2
|
||||||
node_md_disks{device="md11"} 2
|
node_md_disks{device="md11"} 2
|
||||||
node_md_disks{device="md12"} 2
|
node_md_disks{device="md12"} 2
|
||||||
|
node_md_disks{device="md120"} 2
|
||||||
node_md_disks{device="md126"} 2
|
node_md_disks{device="md126"} 2
|
||||||
node_md_disks{device="md127"} 2
|
node_md_disks{device="md127"} 2
|
||||||
node_md_disks{device="md219"} 0
|
node_md_disks{device="md219"} 3
|
||||||
node_md_disks{device="md3"} 8
|
node_md_disks{device="md3"} 8
|
||||||
node_md_disks{device="md4"} 2
|
node_md_disks{device="md4"} 2
|
||||||
node_md_disks{device="md6"} 2
|
node_md_disks{device="md6"} 2
|
||||||
|
@ -1070,11 +1073,12 @@ node_md_disks_active{device="md00"} 1
|
||||||
node_md_disks_active{device="md10"} 2
|
node_md_disks_active{device="md10"} 2
|
||||||
node_md_disks_active{device="md11"} 2
|
node_md_disks_active{device="md11"} 2
|
||||||
node_md_disks_active{device="md12"} 2
|
node_md_disks_active{device="md12"} 2
|
||||||
|
node_md_disks_active{device="md120"} 2
|
||||||
node_md_disks_active{device="md126"} 2
|
node_md_disks_active{device="md126"} 2
|
||||||
node_md_disks_active{device="md127"} 2
|
node_md_disks_active{device="md127"} 2
|
||||||
node_md_disks_active{device="md219"} 0
|
node_md_disks_active{device="md219"} 0
|
||||||
node_md_disks_active{device="md3"} 8
|
node_md_disks_active{device="md3"} 8
|
||||||
node_md_disks_active{device="md4"} 2
|
node_md_disks_active{device="md4"} 0
|
||||||
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
|
||||||
|
@ -1086,6 +1090,7 @@ node_md_is_active{device="md00"} 1
|
||||||
node_md_is_active{device="md10"} 1
|
node_md_is_active{device="md10"} 1
|
||||||
node_md_is_active{device="md11"} 1
|
node_md_is_active{device="md11"} 1
|
||||||
node_md_is_active{device="md12"} 1
|
node_md_is_active{device="md12"} 1
|
||||||
|
node_md_is_active{device="md120"} 1
|
||||||
node_md_is_active{device="md126"} 1
|
node_md_is_active{device="md126"} 1
|
||||||
node_md_is_active{device="md127"} 1
|
node_md_is_active{device="md127"} 1
|
||||||
node_md_is_active{device="md219"} 0
|
node_md_is_active{device="md219"} 0
|
||||||
|
|
|
@ -46,4 +46,7 @@ md219 : inactive sdb[2](S) sdc[1](S) sda[0](S)
|
||||||
md00 : active raid0 xvdb[0]
|
md00 : active raid0 xvdb[0]
|
||||||
4186624 blocks super 1.2 256k chunks
|
4186624 blocks super 1.2 256k chunks
|
||||||
|
|
||||||
|
md120 : active linear sda1[1] sdb1[0]
|
||||||
|
2095104 blocks super 1.2 0k rounding
|
||||||
|
|
||||||
unused devices: <none>
|
unused devices: <none>
|
||||||
|
|
|
@ -29,10 +29,10 @@ import (
|
||||||
|
|
||||||
var (
|
var (
|
||||||
statuslineRE = regexp.MustCompile(`(\d+) blocks .*\[(\d+)/(\d+)\] \[[U_]+\]`)
|
statuslineRE = regexp.MustCompile(`(\d+) blocks .*\[(\d+)/(\d+)\] \[[U_]+\]`)
|
||||||
raid0lineRE = regexp.MustCompile(`(\d+) blocks .*\d+k chunks`)
|
raid0lineRE = regexp.MustCompile(`(\d+) blocks .*\d+k (chunks|rounding)`)
|
||||||
buildlineRE = regexp.MustCompile(`\((\d+)/\d+\)`)
|
buildlineRE = regexp.MustCompile(`\((\d+)/\d+\)`)
|
||||||
unknownPersonalityLineRE = regexp.MustCompile(`(\d+) blocks (.*)`)
|
unknownPersonalityLineRE = regexp.MustCompile(`(\d+) blocks (.*)`)
|
||||||
raidPersonalityRE = regexp.MustCompile(`raid[0-9]+`)
|
raidPersonalityRE = regexp.MustCompile(`^(linear|raid[0-9]+)$`)
|
||||||
)
|
)
|
||||||
|
|
||||||
type mdStatus struct {
|
type mdStatus struct {
|
||||||
|
@ -175,20 +175,25 @@ func parseMdstat(mdStatusFilePath string) ([]mdStatus, error) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
switch {
|
switch {
|
||||||
case personality == "raid0":
|
case personality == "raid0" || personality == "linear":
|
||||||
md.disksActive = int64(len(mainLine) - 4) // Get the number of devices from the main line.
|
md.disksActive = int64(len(mainLine) - 4) // Get the number of devices from the main line.
|
||||||
md.disksTotal = md.disksActive // Raid0 active and total is always the same if active.
|
md.disksTotal = md.disksActive // Raid0 active and total is always the same if active.
|
||||||
md.blocksTotal, err = evalRaid0line(lines[i+1])
|
md.blocksTotal, err = evalRaid0line(lines[i+1])
|
||||||
case raidPersonalityRE.MatchString(personality):
|
case raidPersonalityRE.MatchString(personality):
|
||||||
md.disksActive, md.disksTotal, md.blocksTotal, err = evalStatusline(lines[i+1])
|
md.disksActive, md.disksTotal, md.blocksTotal, err = evalStatusline(lines[i+1])
|
||||||
default:
|
default:
|
||||||
log.Infof("Personality unknown: %s\n", mainLine)
|
log.Debugf("Personality unknown: %s", mainLine)
|
||||||
|
md.disksTotal = int64(len(mainLine) - 3)
|
||||||
md.blocksTotal, err = evalUnknownPersonalitylineRE(lines[i+1])
|
md.blocksTotal, err = evalUnknownPersonalitylineRE(lines[i+1])
|
||||||
}
|
}
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return mdStates, fmt.Errorf("error parsing mdstat: %s", err)
|
return mdStates, fmt.Errorf("error parsing mdstat: %s", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if !md.active {
|
||||||
|
md.disksActive = 0
|
||||||
|
}
|
||||||
|
|
||||||
syncLine := lines[i+2]
|
syncLine := lines[i+2]
|
||||||
if strings.Contains(syncLine, "bitmap") {
|
if strings.Contains(syncLine, "bitmap") {
|
||||||
syncLine = lines[i+3]
|
syncLine = lines[i+3]
|
||||||
|
|
|
@ -28,7 +28,7 @@ func TestMdadm(t *testing.T) {
|
||||||
"md3": {"md3", true, 8, 8, 5853468288, 5853468288},
|
"md3": {"md3", true, 8, 8, 5853468288, 5853468288},
|
||||||
"md127": {"md127", true, 2, 2, 312319552, 312319552},
|
"md127": {"md127", true, 2, 2, 312319552, 312319552},
|
||||||
"md0": {"md0", true, 2, 2, 248896, 248896},
|
"md0": {"md0", true, 2, 2, 248896, 248896},
|
||||||
"md4": {"md4", false, 2, 2, 4883648, 4883648},
|
"md4": {"md4", false, 0, 2, 4883648, 4883648},
|
||||||
"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},
|
||||||
|
@ -36,8 +36,9 @@ func TestMdadm(t *testing.T) {
|
||||||
"md10": {"md10", true, 2, 2, 314159265, 314159265},
|
"md10": {"md10", true, 2, 2, 314159265, 314159265},
|
||||||
"md11": {"md11", true, 2, 2, 4190208, 4190208},
|
"md11": {"md11", true, 2, 2, 4190208, 4190208},
|
||||||
"md12": {"md12", true, 2, 2, 3886394368, 3886394368},
|
"md12": {"md12", true, 2, 2, 3886394368, 3886394368},
|
||||||
|
"md120": {"md120", true, 2, 2, 2095104, 2095104},
|
||||||
"md126": {"md126", true, 2, 2, 1855870976, 1855870976},
|
"md126": {"md126", true, 2, 2, 1855870976, 1855870976},
|
||||||
"md219": {"md219", false, 0, 0, 7932, 7932},
|
"md219": {"md219", false, 0, 3, 7932, 7932},
|
||||||
"md00": {"md00", true, 1, 1, 4186624, 4186624},
|
"md00": {"md00", true, 1, 1, 4186624, 4186624},
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue