Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix analyze_log with threading #570

Merged
merged 2 commits into from
Nov 25, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions handler/analyzer/analyze_log.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
import os
import re
import threading
import uuid

import tabulate

Expand Down Expand Up @@ -214,24 +215,24 @@ def __handle_from_node(self, node, local_store_parent_dir):
from_datetime_timestamp = TimeUtils.timestamp_to_filename_time(TimeUtils.datetime_to_timestamp(self.from_time_str))
to_datetime_timestamp = TimeUtils.timestamp_to_filename_time(TimeUtils.datetime_to_timestamp(self.to_time_str))
gather_dir_name = "ob_log_{0}_{1}_{2}".format(ssh_client.get_name(), from_datetime_timestamp, to_datetime_timestamp)
gather_dir_full_path = "{0}/{1}".format(self.gather_ob_log_temporary_dir, gather_dir_name)
gather_dir_full_path = "{0}/{1}_{2}".format(self.gather_ob_log_temporary_dir, gather_dir_name, str(uuid.uuid4())[:6])
mkdir(ssh_client, gather_dir_full_path)

log_list, resp = self.__handle_log_list(ssh_client, node, resp)
if resp["skip"]:
return resp, node_results
self.stdio.print(FileUtil.show_file_list_tabulate(remote_ip, log_list, self.stdio))
self.stdio.start_loading("analyze log start")
for log_name in log_list:
if self.directly_analyze_files:
self.__pharse_offline_log_file(ssh_client, log_name=log_name, local_store_dir=local_store_dir)
analyze_log_full_path = "{0}/{1}".format(local_store_dir, str(log_name).strip(".").replace("/", "_"))
else:
self.__pharse_log_file(ssh_client, node=node, log_name=log_name, gather_path=gather_dir_full_path, local_store_dir=local_store_dir)
analyze_log_full_path = "{0}/{1}".format(local_store_dir, log_name)
self.stdio.print('analyze log start')
file_result = self.__parse_log_lines(analyze_log_full_path)
self.stdio.print('analyze log sucess')
node_results.append(file_result)
self.stdio.stop_loading("succeed")
delete_file(ssh_client, gather_dir_full_path, self.stdio)
ssh_client.ssh_close()
return resp, node_results
Expand Down
Loading