Skip to content

Commit 4c247a3

Browse files
author
Frederic
authored
Added RecoveringDisks
Signed-off-by: Frederic <[email protected]>
1 parent 54b2b56 commit 4c247a3

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

mdstat.go

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,8 @@ type MDStat struct {
4646
DisksDown int64
4747
// Spare disks in the device.
4848
DisksSpare int64
49+
// Number of "recovering" disks. eg. when running "mdadm /dev/md0 --replace /dev/sdb1 --with /dev/sde1" - disk sde1 is "recovering" until done.
50+
DisksRecovering int64
4951
// Number of blocks the device holds.
5052
BlocksTotal int64
5153
// Number of blocks on the device that are in sync.
@@ -101,9 +103,10 @@ func parseMDStat(mdStatData []byte) ([]MDStat, error) {
101103
return nil, fmt.Errorf("%w: Too few lines for md device: %q", ErrFileParse, mdName)
102104
}
103105

104-
// Failed disks have the suffix (F) & Spare disks have the suffix (S).
106+
// Failed disks have the suffix (F), Spare disks have the suffix (S) & Recovering disks have (R).
105107
fail := int64(strings.Count(line, "(F)"))
106108
spare := int64(strings.Count(line, "(S)"))
109+
disksRecovering := int64(strings.Count(line, "(R)"))
107110
active, total, down, size, err := evalStatusLine(lines[i], lines[i+1])
108111

109112
if err != nil {
@@ -155,6 +158,7 @@ func parseMDStat(mdStatData []byte) ([]MDStat, error) {
155158
DisksFailed: fail,
156159
DisksDown: down,
157160
DisksSpare: spare,
161+
DisksRecovering: disksRecovering,
158162
DisksTotal: total,
159163
BlocksTotal: size,
160164
BlocksSynced: blocksSynced,

0 commit comments

Comments
 (0)