From ecea90d8148e3a17dc205b03bbe7b5f533dcf24e Mon Sep 17 00:00:00 2001 From: Singee Date: Thu, 13 Apr 2023 17:12:47 +0800 Subject: [PATCH] change default type to unknown Signed-off-by: Singee --- mdstat.go | 2 +- mdstat_test.go | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/mdstat.go b/mdstat.go index 80c28e8d..17a0311c 100644 --- a/mdstat.go +++ b/mdstat.go @@ -97,7 +97,7 @@ func parseMDStat(mdStatData []byte) ([]MDStat, error) { mdName := deviceFields[0] // mdx state := deviceFields[2] // active or inactive - mdType := "" + mdType := "unknown" if len(deviceFields) > 3 && isRaidType(deviceFields[3]) { mdType = deviceFields[3] // raid1, raid5, etc. } else if len(deviceFields) > 4 && isRaidType(deviceFields[4]) { diff --git a/mdstat_test.go b/mdstat_test.go index c7f6c0ec..6563bd1b 100644 --- a/mdstat_test.go +++ b/mdstat_test.go @@ -38,7 +38,7 @@ func TestFS_MDStat(t *testing.T) { "md12": {Name: "md12", Type: "raid0", ActivityState: "active", DisksActive: 2, DisksTotal: 2, DisksSpare: 0, DisksDown: 0, DisksFailed: 0, BlocksTotal: 3886394368, BlocksSynced: 3886394368, BlocksSyncedPct: 0, BlocksSyncedFinishTime: 0, BlocksSyncedSpeed: 0, Devices: []string{"sdc2", "sdd2"}}, "md120": {Name: "md120", Type: "linear", ActivityState: "active", DisksActive: 2, DisksTotal: 2, DisksFailed: 0, DisksDown: 0, DisksSpare: 0, BlocksTotal: 2095104, BlocksSynced: 2095104, BlocksSyncedPct: 0, BlocksSyncedFinishTime: 0, BlocksSyncedSpeed: 0, Devices: []string{"sda1", "sdb1"}}, "md126": {Name: "md126", Type: "raid0", ActivityState: "active", DisksActive: 2, DisksTotal: 2, DisksFailed: 0, DisksDown: 0, DisksSpare: 0, BlocksTotal: 1855870976, BlocksSynced: 1855870976, BlocksSyncedPct: 0, BlocksSyncedFinishTime: 0, BlocksSyncedSpeed: 0, Devices: []string{"sdb", "sdc"}}, - "md219": {Name: "md219", Type: "", ActivityState: "inactive", DisksTotal: 0, DisksFailed: 0, DisksActive: 0, DisksDown: 0, DisksSpare: 3, BlocksTotal: 7932, BlocksSynced: 7932, BlocksSyncedPct: 0, BlocksSyncedFinishTime: 0, BlocksSyncedSpeed: 0, Devices: []string{"sdc", "sda"}}, + "md219": {Name: "md219", Type: "unknown", ActivityState: "inactive", DisksTotal: 0, DisksFailed: 0, DisksActive: 0, DisksDown: 0, DisksSpare: 3, BlocksTotal: 7932, BlocksSynced: 7932, BlocksSyncedPct: 0, BlocksSyncedFinishTime: 0, BlocksSyncedSpeed: 0, Devices: []string{"sdc", "sda"}}, "md00": {Name: "md00", Type: "raid0", ActivityState: "active", DisksActive: 1, DisksTotal: 1, DisksFailed: 0, DisksDown: 0, DisksSpare: 0, BlocksTotal: 4186624, BlocksSynced: 4186624, BlocksSyncedPct: 0, BlocksSyncedFinishTime: 0, BlocksSyncedSpeed: 0, Devices: []string{"xvdb"}}, "md101": {Name: "md101", Type: "raid0", ActivityState: "active", DisksActive: 3, DisksTotal: 3, DisksFailed: 0, DisksDown: 0, DisksSpare: 0, BlocksTotal: 322560, BlocksSynced: 322560, BlocksSyncedPct: 0, BlocksSyncedFinishTime: 0, BlocksSyncedSpeed: 0, Devices: []string{"sdb", "sdd", "sdc"}}, "md201": {Name: "md201", Type: "raid1", ActivityState: "checking", DisksActive: 2, DisksTotal: 2, DisksFailed: 0, DisksDown: 0, DisksSpare: 0, BlocksTotal: 1993728, BlocksSynced: 114176, BlocksSyncedPct: 5.7, BlocksSyncedFinishTime: 0.2, BlocksSyncedSpeed: 114176, Devices: []string{"sda3", "sdb3"}},