From 2bdf04a5751866ac511ab17a86bfd4dcac65ceb9 Mon Sep 17 00:00:00 2001 From: zhanghan2021 Date: Mon, 20 Nov 2023 15:50:39 +0800 Subject: [PATCH] add cpu class and get cpu info func --- category/get_cpu_info.py | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100644 category/get_cpu_info.py diff --git a/category/get_cpu_info.py b/category/get_cpu_info.py new file mode 100644 index 0000000..1897b3b --- /dev/null +++ b/category/get_cpu_info.py @@ -0,0 +1,29 @@ +#!/usr/bin/env python +# -*- coding: UTF-8 -*- +# cython:language_level=3 + +from common.file import FileOperation +from common.command import Command +from common.global_parameter import GlobalParameter + +# CPU class +class CPUInfo: + def __init__(self, t_fileName): + self.__default_file_name = t_fileName + FileOperation.remove_txt_file(self.__default_file_name) + # 默认时间间隔 + self.__interval = GlobalParameter().get_cpu_interval + # 默认执行次数 + self.__times = GlobalParameter().get_cpu_times + + # getInfo + def get_info(self): + self.__get_cpu_info() + self.__get_top_info(self.__interval, self.__times) + + #多线程执行命令,间隔self.__interval秒,运行self.__times次 + #必须放在一起,保证命令启动时间一致 + self.__get_pid_cpustat_info() + self.__get_mpstat_info(self.__interval, self.__times) + self.__get_sar_info(self.__interval, self.__times) + self.__get_numastat_info() \ No newline at end of file -- Gitee