From b778b1d503cc3f5bd934fdd5eef5505b13d47589 Mon Sep 17 00:00:00 2001 From: cnphpbb Date: Fri, 12 Sep 2025 16:29:25 +0800 Subject: [PATCH] =?UTF-8?q?docs(INSTALL):=20=E6=9B=B4=E6=96=B0=E5=AE=89?= =?UTF-8?q?=E8=A3=85=E6=96=87=E6=A1=A3=E4=B8=AD=E7=9A=84=E4=BE=9D=E8=B5=96?= =?UTF-8?q?=E5=AE=89=E8=A3=85=E5=91=BD=E4=BB=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit refactor(disk_inspection): 修改megaraid控制器数量配置逻辑 更新安装文档中的Python和pip安装命令,确保兼容性 重构disk_inspection.py中的控制器数量配置,使用起始和结束值更清晰地定义megaraid控制器范围 --- crontab/INSTALL.md | 6 ++++-- crontab/disk_inspection.py | 8 +++++--- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/crontab/INSTALL.md b/crontab/INSTALL.md index dfd2433..93d71b9 100644 --- a/crontab/INSTALL.md +++ b/crontab/INSTALL.md @@ -20,7 +20,7 @@ ### Ubuntu/Debian ```bash sudo apt-get update -sudo apt-get install smartmontools +sudo apt-get install smartmontools ``` ### CentOS/RHEL @@ -40,6 +40,8 @@ sudo dnf install smartmontools ```bash python --version # 或 python3 --version pip --version # 或 pip3 --version +apt install -y python3-pip +apt install python3.11-venv ``` 如果您的系统中没有安装Python或pip,请先安装它们。 @@ -69,7 +71,7 @@ pip3 install -r requirements.txt ```bash # 创建虚拟环境 -python -m venv venv +python3 -m venv venv # 激活虚拟环境 # Linux/MacOS diff --git a/crontab/disk_inspection.py b/crontab/disk_inspection.py index cadc51c..6c46575 100644 --- a/crontab/disk_inspection.py +++ b/crontab/disk_inspection.py @@ -3,7 +3,8 @@ # 配置项 DEFAULT_DEVICE = "/dev/sda" # 默认检查的设备路径 -DEFAULT_CONTROLLER_COUNT = 8 # 默认控制器数量 +DEFAULT_MEGARAID_BINEG = 8 # megaraid起始值 +DEFAULT_MEGARAID_END = 15 # megaraid结束值 DEFAULT_LOG_DIR = "/root" # 默认日志目录 MCP_SERVER_URL = "http://10.10.13.143:4527/mcp/v1/submit" # MCP服务器提交接口 CRITICAL_ATTRIBUTES = ["Reallocated_Sector_Ct", "Spin_Retry_Count", @@ -19,9 +20,10 @@ import json import requests class DiskInspection: - def __init__(self, device=DEFAULT_DEVICE, controller_count=DEFAULT_CONTROLLER_COUNT, log_dir=DEFAULT_LOG_DIR): + def __init__(self, device=DEFAULT_DEVICE, controller_count=DEFAULT_MEGARAID_BINEG, log_dir=DEFAULT_LOG_DIR): self.device = device self.controller_count = controller_count + self.megaraid_count = DEFAULT_MEGARAID_END + 1 # 默认megaraid控制器数量 self.log_dir = log_dir self.current_date = datetime.datetime.now().strftime("%y%m%d") self.log_file = os.path.join(log_dir, f"smartctl.{self.current_date}.log") @@ -428,7 +430,7 @@ class DiskInspection: open(self.log_file, 'w').close() # 检查每个控制器 - for controller_id in range(self.controller_count): + for controller_id in range(self.controller_count, self.megaraid_count): print(f"检查控制器 {controller_id}...") output = self.run_smartctl(controller_id) if output: