Explorar o código

Removed some unneeded data in output

Toby Chui hai 1 ano
pai
achega
0a96f07efc
Modificáronse 1 ficheiros con 8 adicións e 16 borrados
  1. 8 16
      mod/disk/raid/raiddetails.go

+ 8 - 16
mod/disk/raid/raiddetails.go

@@ -33,11 +33,7 @@ type RAIDInfo struct {
 
 // DeviceInfo represents information about a device in a RAID array.
 type DeviceInfo struct {
-	Number     int
-	Major      int
-	Minor      int
-	RaidDevice int
-	State      string
+	State      []string
 	DevicePath string
 }
 
@@ -107,14 +103,10 @@ func parseRAIDInfo(output string) *RAIDInfo {
 			case "Events":
 				raidInfo.Events, _ = strconv.Atoi(fields[2])
 			default:
-				if len(fields) == 6 && fields[0] != "Number" {
+				if len(fields) >= 6 && fields[0] != "Number" {
 					deviceInfo := DeviceInfo{}
-					deviceInfo.Number, _ = strconv.Atoi(fields[0])
-					deviceInfo.Major, _ = strconv.Atoi(fields[1])
-					deviceInfo.Minor, _ = strconv.Atoi(fields[2])
-					deviceInfo.RaidDevice, _ = strconv.Atoi(fields[3])
-					deviceInfo.State = fields[4]
-					deviceInfo.DevicePath = fields[5]
+					deviceInfo.State = fields[4 : len(fields)-1]
+					deviceInfo.DevicePath = fields[len(fields)-1]
 					raidInfo.DeviceInfo = append(raidInfo.DeviceInfo, deviceInfo)
 				}
 			}
@@ -130,8 +122,8 @@ func (info *RAIDInfo) PrettyPrintRAIDInfo() {
 	fmt.Printf("  Version: %s\n", info.Version)
 	fmt.Printf("  Creation Time: %s\n", info.CreationTime.Format("Mon Jan 02 15:04:05 2006"))
 	fmt.Printf("  Raid Level: %s\n", info.RaidLevel)
-	fmt.Printf("  Array Size: %s\n", info.ArraySize)
-	fmt.Printf("  Used Dev Size: %s\n", info.UsedDevSize)
+	fmt.Printf("  Array Size: %d\n", info.ArraySize)
+	fmt.Printf("  Used Dev Size: %d\n", info.UsedDevSize)
 	fmt.Printf("  Raid Devices: %d\n", info.RaidDevices)
 	fmt.Printf("  Total Devices: %d\n", info.TotalDevices)
 	fmt.Printf("  Persistence: %s\n", info.Persistence)
@@ -147,8 +139,8 @@ func (info *RAIDInfo) PrettyPrintRAIDInfo() {
 	fmt.Printf("  Events: %d\n", info.Events)
 
 	fmt.Println("\nDevice Information:")
-	fmt.Printf("%-10s %-10s %-10s %-12s %-10s %s\n", "Number", "Major", "Minor", "RaidDevice", "State", "DevicePath")
+	fmt.Printf("%s %s\n", "State", "DevicePath")
 	for _, device := range info.DeviceInfo {
-		fmt.Printf("%-10d %-10d %-10d %-12d %-10s %s\n", device.Number, device.Major, device.Minor, device.RaidDevice, device.State, device.DevicePath)
+		fmt.Printf("%s %s\n", strings.Join(device.State, ","), device.DevicePath)
 	}
 }