fix(disk_inspection): 修正控制器范围遍历从controller_count到megaraid_count

This commit is contained in:
cnphpbb
2025-09-12 17:36:41 +08:00
parent b778b1d503
commit 52c130e9c6

View File

@@ -267,7 +267,7 @@ class DiskInspection:
f.write("| 控制器ID | 硬盘类型 | 厂商 | 设备型号 | 序列号 | 健康状态 | 温度(°C) | 通电时间 |\n") f.write("| 控制器ID | 硬盘类型 | 厂商 | 设备型号 | 序列号 | 健康状态 | 温度(°C) | 通电时间 |\n")
f.write("|----------|----------|------|----------|--------|----------|----------|----------|\n") f.write("|----------|----------|------|----------|--------|----------|----------|----------|\n")
for controller_id in range(self.controller_count): for controller_id in range(self.controller_count, self.megaraid_count):
info = self.results.get(controller_id, {}) info = self.results.get(controller_id, {})
if "health_status" in info: # 只显示有数据的控制器 if "health_status" in info: # 只显示有数据的控制器
f.write(f"| {controller_id} ") f.write(f"| {controller_id} ")
@@ -283,7 +283,7 @@ class DiskInspection:
f.write("\n## 控制器详细信息\n\n") f.write("\n## 控制器详细信息\n\n")
has_issues = False has_issues = False
for controller_id in range(self.controller_count): for controller_id in range(self.controller_count, self.megaraid_count):
info = self.results.get(controller_id, {}) info = self.results.get(controller_id, {})
if "health_status" in info: # 只显示有数据的控制器 if "health_status" in info: # 只显示有数据的控制器
f.write(f"### 控制器 {controller_id}\n") f.write(f"### 控制器 {controller_id}\n")
@@ -330,7 +330,7 @@ class DiskInspection:
f.write("\n## 异常汇总\n\n") f.write("\n## 异常汇总\n\n")
if has_issues: if has_issues:
f.write("**发现异常控制器,请关注以下问题:**\n\n") f.write("**发现异常控制器,请关注以下问题:**\n\n")
for controller_id in range(self.controller_count): for controller_id in range(self.controller_count, self.megaraid_count):
info = self.results.get(controller_id, {}) info = self.results.get(controller_id, {})
if info.get("health_status", "") not in ["OK", "PASSED"]: if info.get("health_status", "") not in ["OK", "PASSED"]:
f.write(f"- **控制器 {controller_id}**: 状态为 {info.get('health_status', '未知')}\n") f.write(f"- **控制器 {controller_id}**: 状态为 {info.get('health_status', '未知')}\n")