From 695d1bda33c89f3f228ff44cc225acb3e5322ec3 Mon Sep 17 00:00:00 2001 From: wayyoungboy <35394786+wayyoungboy@users.noreply.github.com> Date: Wed, 24 Jul 2024 15:38:22 +0800 Subject: [PATCH 1/2] 2.3.0 fix analyze_log offline (#365) * clog update * build * update * update * update * update rca clog_disk_full_scene * del SsherClient SafeStdio super init func * update lock_conflict_scene * update clog_disk_full_scene * fix analyze_log offline * fix analyze_log offline --- handler/analyzer/analyze_log.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/handler/analyzer/analyze_log.py b/handler/analyzer/analyze_log.py index 434211e6..d018f36f 100644 --- a/handler/analyzer/analyze_log.py +++ b/handler/analyzer/analyze_log.py @@ -31,6 +31,7 @@ from common.tool import DirectoryUtil from common.tool import FileUtil from common.tool import TimeUtils +import common.ssh_client.local_client as ssh_client_local_client class AnalyzeLogHandler(BaseShellHandler): @@ -279,11 +280,13 @@ def __pharse_offline_log_file(self, ssh_client, log_name, local_store_dir): :param ssh_helper, log_name :return: """ + + ssh_client = ssh_client_local_client.LocalClient(context=self.context, node={"ssh_type": "local"}) local_store_path = "{0}/{1}".format(local_store_dir, str(log_name).strip(".").replace("/", "_")) if self.grep_args is not None: grep_cmd = "grep -e '{grep_args}' {log_name} >> {local_store_path} ".format(grep_args=self.grep_args, log_name=log_name, local_store_path=local_store_path) self.stdio.verbose("grep files, run cmd = [{0}]".format(grep_cmd)) - ssh_client.exec_cmd(ssh_client, grep_cmd) + ssh_client.exec_cmd(grep_cmd) else: download_file(ssh_client, log_name, local_store_path, self.stdio) From 0d7c4e9ea77e402f8ae075b2989ba373a41dd8a8 Mon Sep 17 00:00:00 2001 From: wayyoungboy <35394786+wayyoungboy@users.noreply.github.com> Date: Wed, 24 Jul 2024 17:16:11 +0800 Subject: [PATCH 2/2] fix analyze_log offline (#367) * clog update * build * update * update * update * update rca clog_disk_full_scene * del SsherClient SafeStdio super init func * update lock_conflict_scene * update clog_disk_full_scene * fix analyze_log offline * fix analyze_log offline * fix analyze_log offline * fix analyze_log offline --- handler/analyzer/analyze_log.py | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/handler/analyzer/analyze_log.py b/handler/analyzer/analyze_log.py index d018f36f..439f7928 100644 --- a/handler/analyzer/analyze_log.py +++ b/handler/analyzer/analyze_log.py @@ -132,9 +132,20 @@ def handle(self): local_store_parent_dir = os.path.join(self.gather_pack_dir, "obdiag_analyze_pack_{0}".format(TimeUtils.timestamp_to_filename_time(TimeUtils.get_current_us_timestamp()))) self.stdio.verbose("Use {0} as pack dir.".format(local_store_parent_dir)) analyze_tuples = [] - for node in self.nodes: + + def handle_from_node(node): resp, node_results = self.__handle_from_node(node, local_store_parent_dir) analyze_tuples.append((node.get("ip"), False, resp["error"], node_results)) + + if self.is_ssh: + for node in self.nodes: + handle_from_node(node) + else: + local_ip = '127.0.0.1' + node = self.nodes[0] + node["ip"] = local_ip + handle_from_node(node) + self.stdio.start_loading('analyze result start') title, field_names, summary_list, summary_details_list = self.__get_overall_summary(analyze_tuples, self.directly_analyze_files) table = tabulate.tabulate(summary_list, headers=field_names, tablefmt="grid", showindex=False)