import sys import os # 获取当前脚本的绝对路径 current_dir = os.path.dirname(os.path.abspath(__file__)) # 构建预定系统的绝对路径 预定系统_path = os.path.abspath(os.path.join(current_dir, '..','..','..','..')) # 添加路径 sys.path.append(预定系统_path) # 导入模块 from 预定系统.Base.base import * class Server_monitoring_0001: """ 执行指令: 1.cd 预定系统 2.hytest --report_title 会议预约测试报告 --report_url_prefix http://192.168.1.225 --test 展厅补充会议创建_001 """ tags = ['展厅巡检','服务器状态巡检'] def teststeps(self): i = 0 # 使用示例 url = "http://192.168.5.200:8081/media/cmdb/service_info/check.txt" save_path = "check.txt" extract_info = ['[m]ysql', '[r]edis', '[f]dfs_storaged', '[f]dfs_tracker', '[e]mqx', 'ubains-meeting-api-1.0-SNAPSHOT.jar', 'ubains-meeting-inner-api-1.0-SNAPSHOT.jar', 'uwsgi'] info = fetch_and_parse_check_txt(url, save_path, extract_info) if info: for key, value in info.items(): STEP(++i, f"服务器{key} 服务状态巡检") INFO(f"监测到{key} 服务的状态:{value}") CHECK_POINT(f"{key} 服务状态是否正常", value == '服务正常') else: INFO("无法获取或解析文件内容")