forked from DevOps/deploy.stack
docs(INSTALL): 更新安装文档中的依赖安装命令
refactor(disk_inspection): 修改megaraid控制器数量配置逻辑 更新安装文档中的Python和pip安装命令,确保兼容性 重构disk_inspection.py中的控制器数量配置,使用起始和结束值更清晰地定义megaraid控制器范围
This commit is contained in:
@@ -40,6 +40,8 @@ sudo dnf install smartmontools
|
|||||||
```bash
|
```bash
|
||||||
python --version # 或 python3 --version
|
python --version # 或 python3 --version
|
||||||
pip --version # 或 pip3 --version
|
pip --version # 或 pip3 --version
|
||||||
|
apt install -y python3-pip
|
||||||
|
apt install python3.11-venv
|
||||||
```
|
```
|
||||||
|
|
||||||
如果您的系统中没有安装Python或pip,请先安装它们。
|
如果您的系统中没有安装Python或pip,请先安装它们。
|
||||||
@@ -69,7 +71,7 @@ pip3 install -r requirements.txt
|
|||||||
|
|
||||||
```bash
|
```bash
|
||||||
# 创建虚拟环境
|
# 创建虚拟环境
|
||||||
python -m venv venv
|
python3 -m venv venv
|
||||||
|
|
||||||
# 激活虚拟环境
|
# 激活虚拟环境
|
||||||
# Linux/MacOS
|
# Linux/MacOS
|
||||||
|
|||||||
@@ -3,7 +3,8 @@
|
|||||||
|
|
||||||
# 配置项
|
# 配置项
|
||||||
DEFAULT_DEVICE = "/dev/sda" # 默认检查的设备路径
|
DEFAULT_DEVICE = "/dev/sda" # 默认检查的设备路径
|
||||||
DEFAULT_CONTROLLER_COUNT = 8 # 默认控制器数量
|
DEFAULT_MEGARAID_BINEG = 8 # megaraid起始值
|
||||||
|
DEFAULT_MEGARAID_END = 15 # megaraid结束值
|
||||||
DEFAULT_LOG_DIR = "/root" # 默认日志目录
|
DEFAULT_LOG_DIR = "/root" # 默认日志目录
|
||||||
MCP_SERVER_URL = "http://10.10.13.143:4527/mcp/v1/submit" # MCP服务器提交接口
|
MCP_SERVER_URL = "http://10.10.13.143:4527/mcp/v1/submit" # MCP服务器提交接口
|
||||||
CRITICAL_ATTRIBUTES = ["Reallocated_Sector_Ct", "Spin_Retry_Count",
|
CRITICAL_ATTRIBUTES = ["Reallocated_Sector_Ct", "Spin_Retry_Count",
|
||||||
@@ -19,9 +20,10 @@ import json
|
|||||||
import requests
|
import requests
|
||||||
|
|
||||||
class DiskInspection:
|
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.device = device
|
||||||
self.controller_count = controller_count
|
self.controller_count = controller_count
|
||||||
|
self.megaraid_count = DEFAULT_MEGARAID_END + 1 # 默认megaraid控制器数量
|
||||||
self.log_dir = log_dir
|
self.log_dir = log_dir
|
||||||
self.current_date = datetime.datetime.now().strftime("%y%m%d")
|
self.current_date = datetime.datetime.now().strftime("%y%m%d")
|
||||||
self.log_file = os.path.join(log_dir, f"smartctl.{self.current_date}.log")
|
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()
|
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}...")
|
print(f"检查控制器 {controller_id}...")
|
||||||
output = self.run_smartctl(controller_id)
|
output = self.run_smartctl(controller_id)
|
||||||
if output:
|
if output:
|
||||||
|
|||||||
Reference in New Issue
Block a user