01服务器状态监测.py 1.4 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
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 预定系统
18
            2.hytest --report_title 会议预约测试报告 --report_url_prefix http://nat.ubainsyun.com:31133 --test 展厅补充会议创建_001
19 20
    """
    tags = ['展厅巡检','服务器状态巡检']
21

22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39

    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("无法获取或解析文件内容")