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: