Skip to content

Commit

Permalink
fix analyze_log with threading (#570)
Browse files Browse the repository at this point in the history
* update loading

* fix analyze_log with threading
  • Loading branch information
wayyoungboy authored Nov 25, 2024
1 parent 1db71c8 commit 0cec00b
Showing 1 changed file with 4 additions and 3 deletions.
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

0 comments on commit 0cec00b

Please sign in to comment.