Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added DisksRecovering #676

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion mdstat.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,8 @@ type MDStat struct {
DisksDown int64
// Spare disks in the device.
DisksSpare int64
// Number of "recovering" disks. eg. when running "mdadm /dev/md0 --replace /dev/sdb1 --with /dev/sde1" - disk sde1 is "recovering" until done.
DisksRecovering int64
// Number of blocks the device holds.
BlocksTotal int64
// Number of blocks on the device that are in sync.
Expand Down Expand Up @@ -101,9 +103,10 @@ func parseMDStat(mdStatData []byte) ([]MDStat, error) {
return nil, fmt.Errorf("%w: Too few lines for md device: %q", ErrFileParse, mdName)
}

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

if err != nil {
Expand Down Expand Up @@ -155,6 +158,7 @@ func parseMDStat(mdStatData []byte) ([]MDStat, error) {
DisksFailed: fail,
DisksDown: down,
DisksSpare: spare,
DisksRecovering: disksRecovering,
DisksTotal: total,
BlocksTotal: size,
BlocksSynced: blocksSynced,
Expand Down