diff --git a/handler/analyzer/analyze_log.py b/handler/analyzer/analyze_log.py index b15f7f6b..e88dc2a9 100644 --- a/handler/analyzer/analyze_log.py +++ b/handler/analyzer/analyze_log.py @@ -151,10 +151,15 @@ def handle_from_node(node): self.stdio.print("analyze nodes's log start. Please wait a moment...") self.stdio.start_loading('analyze start') for node in self.nodes: - if not self.is_ssh: - local_ip = NetUtils.get_inner_ip() - node = self.nodes[0] - node["ip"] = local_ip + if self.directly_analyze_files: + if nodes_threads: + break + node["ip"] = '127.0.0.1' + else: + if not self.is_ssh: + local_ip = NetUtils.get_inner_ip() + node = self.nodes[0] + node["ip"] = local_ip node_threads = threading.Thread(target=handle_from_node, args=(node,)) node_threads.start() nodes_threads.append(node_threads) diff --git a/handler/analyzer/analyze_memory.py b/handler/analyzer/analyze_memory.py index e532107c..c4968468 100644 --- a/handler/analyzer/analyze_memory.py +++ b/handler/analyzer/analyze_memory.py @@ -64,7 +64,8 @@ def init_config(self): self.file_number_limit = int(basic_config["file_number_limit"]) self.file_size_limit = int(FileUtil.size(basic_config["file_size_limit"])) self.config_path = basic_config['config_path'] - self.version = self.get_version() + if self.version is None: + self.version = self.get_version() return True def init_option(self): @@ -81,7 +82,11 @@ def init_option(self): self.is_ssh = False self.directly_analyze_files = True self.analyze_files_list = files_option - self.version = version + if version: + self.version = version + else: + self.stdio.error('the option --files requires the --version option to be specified') + return False if from_option is not None and to_option is not None: try: from_timestamp = TimeUtils.parse_time_str(from_option) @@ -155,10 +160,15 @@ def handle_from_node(node): self.stdio.print("analyze nodes's log start. Please wait a moment...") self.stdio.start_loading('analyze memory start') for node in self.nodes: - if not self.is_ssh: - local_ip = NetUtils.get_inner_ip() - node = self.nodes[0] - node["ip"] = local_ip + if self.directly_analyze_files: + if nodes_threads: + break + node["ip"] = '127.0.0.1' + else: + if not self.is_ssh: + local_ip = NetUtils.get_inner_ip() + node = self.nodes[0] + node["ip"] = local_ip node_threads = threading.Thread(target=handle_from_node, args=(node,)) node_threads.start() nodes_threads.append(node_threads) @@ -230,7 +240,10 @@ def __handle_from_node(self, node, local_store_parent_dir): try: fig = go.Figure() colors = ['blue', 'orange', 'green', 'red', 'purple', 'cyan', 'magenta', 'yellow', 'black', 'brown', 'pink', 'gray', 'lime', 'teal', 'navy'] - if len(tenant_memory_info_dict) < 20: + if len(tenant_memory_info_dict) == 0: + resp["skip"] = True + resp["error"] = "failed to analyze memory data from the log" + elif len(tenant_memory_info_dict) < 20 and len(tenant_memory_info_dict) > 0: i = 0 x_lines = [] x_vals = [] @@ -313,61 +326,61 @@ def __handle_from_node(self, node, local_store_parent_dir): html_fig_ctx = pio.to_html(fig_ctx, full_html=False) html_fig_mod = pio.to_html(fig_mod, full_html=False) html_combined = ''' - -
-