From 2279091a9df7c9c8314cb359df216404137826d1 Mon Sep 17 00:00:00 2001 From: Miryam Schwartz Date: Wed, 4 Dec 2024 17:53:21 +0200 Subject: [PATCH 1/5] Add the collectx versions to the to the PFD --- .../log_analyzers/ibdiagnet2_port_counters_analyzer.py | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/plugins/ufm_log_analyzer_plugin/src/loganalyze/log_analyzers/ibdiagnet2_port_counters_analyzer.py b/plugins/ufm_log_analyzer_plugin/src/loganalyze/log_analyzers/ibdiagnet2_port_counters_analyzer.py index a809e4a0..826a9c74 100644 --- a/plugins/ufm_log_analyzer_plugin/src/loganalyze/log_analyzers/ibdiagnet2_port_counters_analyzer.py +++ b/plugins/ufm_log_analyzer_plugin/src/loganalyze/log_analyzers/ibdiagnet2_port_counters_analyzer.py @@ -40,6 +40,7 @@ def __init__( self.save_first_last_iteration_timestamp, self.save_number_of_switches_and_ports, self.save_number_of_core_dumps, + self.save_collectx_versions } # Based on the log path, decided if this is primary or secondary if "ufm_logs" in logs_csvs[0]: @@ -52,11 +53,16 @@ def __init__( self._first_timestamp_of_logs = None self._last_timestamp_of_logs = None - def get_collectx_versions(self): + def save_collectx_versions(self): unique_collectx_versions = self._log_data_sorted[ self._log_data_sorted["type"] == "collectx_version" ]["data"].unique() - return unique_collectx_versions + self._dataframes_for_pdf.append( + ( + f"{self.telemetry_type} telemetry collectx versions", + unique_collectx_versions, + ) + ) def save_number_of_switches_and_ports(self): """ From fa0d725580061628edcf21986b370348ca327a87 Mon Sep 17 00:00:00 2001 From: Miryam Schwartz Date: Thu, 5 Dec 2024 09:51:44 +0200 Subject: [PATCH 2/5] change title --- .../log_analyzers/ibdiagnet2_port_counters_analyzer.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/plugins/ufm_log_analyzer_plugin/src/loganalyze/log_analyzers/ibdiagnet2_port_counters_analyzer.py b/plugins/ufm_log_analyzer_plugin/src/loganalyze/log_analyzers/ibdiagnet2_port_counters_analyzer.py index 826a9c74..b89f9c86 100644 --- a/plugins/ufm_log_analyzer_plugin/src/loganalyze/log_analyzers/ibdiagnet2_port_counters_analyzer.py +++ b/plugins/ufm_log_analyzer_plugin/src/loganalyze/log_analyzers/ibdiagnet2_port_counters_analyzer.py @@ -40,7 +40,7 @@ def __init__( self.save_first_last_iteration_timestamp, self.save_number_of_switches_and_ports, self.save_number_of_core_dumps, - self.save_collectx_versions + self.save_collectx_versions, } # Based on the log path, decided if this is primary or secondary if "ufm_logs" in logs_csvs[0]: @@ -59,7 +59,7 @@ def save_collectx_versions(self): ]["data"].unique() self._dataframes_for_pdf.append( ( - f"{self.telemetry_type} telemetry collectx versions", + f"collectx versions found in {self.telemetry_type} telemetry log", unique_collectx_versions, ) ) From 370ce7381b23355b09b6d5a453d444c7a5936d08 Mon Sep 17 00:00:00 2001 From: Miryam Schwartz Date: Thu, 5 Dec 2024 17:14:55 +0200 Subject: [PATCH 3/5] refactor --- .../src/loganalyze/log_analyzer.py | 13 +++++-------- .../src/loganalyze/log_analyzers/base_analyzer.py | 4 ++++ .../log_analyzers/console_log_analyzer.py | 10 +++++++++- .../ibdiagnet2_port_counters_analyzer.py | 10 ++++------ .../loganalyze/log_analyzers/ufm_top_analyzer.py | 4 +++- .../src/loganalyze/pdf_creator.py | 7 ++++--- 6 files changed, 29 insertions(+), 19 deletions(-) diff --git a/plugins/ufm_log_analyzer_plugin/src/loganalyze/log_analyzer.py b/plugins/ufm_log_analyzer_plugin/src/loganalyze/log_analyzer.py index bc4bddb1..15422650 100755 --- a/plugins/ufm_log_analyzer_plugin/src/loganalyze/log_analyzer.py +++ b/plugins/ufm_log_analyzer_plugin/src/loganalyze/log_analyzer.py @@ -28,6 +28,8 @@ import traceback from typing import Callable, List, Set, Tuple +from numpy import extract + from loganalyze.log_analyzers.base_analyzer import BaseImageCreator from loganalyze.logs_extraction.directory_extractor import DirectoryExtractor @@ -369,7 +371,7 @@ def create_analyzer( end = time.perf_counter() log.LOGGER.debug(f"Took {end-start:.3f} to load the parsed data") - all_images_outputs_and_title, dataframes_for_pdf, txt_for_pdf = ( + all_images_outputs_and_title, dataframes_for_pdf, lists_for_pdf, txt_for_pdf = ( ufm_top_analyzer.full_analysis_all_analyzers() ) @@ -385,13 +387,8 @@ def create_analyzer( pdf_path = os.path.join(args.destination, "UFM_Dump_analysis.pdf") pdf_header = f"{os.path.basename(args.location)}, hours={args.hours}" - used_ufm_version = console_log_analyzer.ufm_versions - text_to_show_in_pdf = ( - f"Used ufm version in console log {used_ufm_version}{os.linesep}" - ) - - pdf = PDFCreator(pdf_path, pdf_header, png_images, text_to_show_in_pdf) - pdf.create_pdf(dataframes_for_pdf, txt_for_pdf) + pdf = PDFCreator(pdf_path, pdf_header, png_images, txt_for_pdf) + pdf.create_pdf(dataframes_for_pdf, lists_for_pdf) # Generated a report that can be located in the destination log.LOGGER.info("Analysis is done, please see the following outputs:") diff --git a/plugins/ufm_log_analyzer_plugin/src/loganalyze/log_analyzers/base_analyzer.py b/plugins/ufm_log_analyzer_plugin/src/loganalyze/log_analyzers/base_analyzer.py index a95ca640..a20d6221 100644 --- a/plugins/ufm_log_analyzer_plugin/src/loganalyze/log_analyzers/base_analyzer.py +++ b/plugins/ufm_log_analyzer_plugin/src/loganalyze/log_analyzers/base_analyzer.py @@ -53,6 +53,7 @@ def __init__(self, dest_image_path): self._dest_image_path = dest_image_path self._images_created = [] self._dataframes_for_pdf = [] + self._lists_for_pdf = [] self._txt_for_pdf = [] self._funcs_for_analysis = set() @@ -165,6 +166,9 @@ def get_images_created(self): def get_dataframes_for_pdf(self): return self._dataframes_for_pdf + + def get_lists_for_pdf(self): + return self._lists_for_pdf def get_txt_for_pdf(self): return self._txt_for_pdf diff --git a/plugins/ufm_log_analyzer_plugin/src/loganalyze/log_analyzers/console_log_analyzer.py b/plugins/ufm_log_analyzer_plugin/src/loganalyze/log_analyzers/console_log_analyzer.py index 1c0301fc..9b34ec99 100644 --- a/plugins/ufm_log_analyzer_plugin/src/loganalyze/log_analyzers/console_log_analyzer.py +++ b/plugins/ufm_log_analyzer_plugin/src/loganalyze/log_analyzers/console_log_analyzer.py @@ -28,7 +28,10 @@ def __init__( self.fix_lines_with_no_timestamp(logs_csvs) super().__init__(logs_csvs, hours, dest_image_path, sort_timestamp) self._log_data_sorted.dropna(subset=["data"], inplace=True) - self._funcs_for_analysis = {self.print_exceptions_per_time_count} + self._funcs_for_analysis = { + self.print_exceptions_per_time_count, + self.save_ufm_versions, + } @staticmethod def _extract_ufm_version(logs_csvs): @@ -104,6 +107,11 @@ def print_exceptions_per_time_count(self): "Time", "Amount of exceptions", "Exceptions count", + ) + + def save_ufm_versions(self): + self._txt_for_pdf.append( + f"Used ufm version in console log {self.ufm_versions}{os.linesep}" ) def full_analysis(self): diff --git a/plugins/ufm_log_analyzer_plugin/src/loganalyze/log_analyzers/ibdiagnet2_port_counters_analyzer.py b/plugins/ufm_log_analyzer_plugin/src/loganalyze/log_analyzers/ibdiagnet2_port_counters_analyzer.py index b89f9c86..3f37912d 100644 --- a/plugins/ufm_log_analyzer_plugin/src/loganalyze/log_analyzers/ibdiagnet2_port_counters_analyzer.py +++ b/plugins/ufm_log_analyzer_plugin/src/loganalyze/log_analyzers/ibdiagnet2_port_counters_analyzer.py @@ -42,6 +42,7 @@ def __init__( self.save_number_of_core_dumps, self.save_collectx_versions, } + # Based on the log path, decided if this is primary or secondary if "ufm_logs" in logs_csvs[0]: self.telemetry_type = "primary" @@ -57,11 +58,8 @@ def save_collectx_versions(self): unique_collectx_versions = self._log_data_sorted[ self._log_data_sorted["type"] == "collectx_version" ]["data"].unique() - self._dataframes_for_pdf.append( - ( - f"collectx versions found in {self.telemetry_type} telemetry log", - unique_collectx_versions, - ) + self._txt_for_pdf.append( + f"collectx versions found in {self.telemetry_type} telemetry log {set(unique_collectx_versions)}" ) def save_number_of_switches_and_ports(self): @@ -222,7 +220,7 @@ def save_number_of_core_dumps(self): self._log_data_sorted["type"] == "timeout_dump_core" ] num = {"Amount": len(core_dumps)} - self._txt_for_pdf.append( + self._lists_for_pdf.append( ( [num], f"{self.telemetry_type} number of core dumps found in the logs", diff --git a/plugins/ufm_log_analyzer_plugin/src/loganalyze/log_analyzers/ufm_top_analyzer.py b/plugins/ufm_log_analyzer_plugin/src/loganalyze/log_analyzers/ufm_top_analyzer.py index 2c6b678a..c0b02274 100644 --- a/plugins/ufm_log_analyzer_plugin/src/loganalyze/log_analyzers/ufm_top_analyzer.py +++ b/plugins/ufm_log_analyzer_plugin/src/loganalyze/log_analyzers/ufm_top_analyzer.py @@ -29,10 +29,12 @@ def full_analysis_all_analyzers(self): graphs_and_titles = [] dataframes = [] + lists = [] txt = [] for analyzer in self._analyzers: graphs_and_titles.extend(analyzer.get_images_created()) dataframes.extend(analyzer.get_dataframes_for_pdf()) + lists.extend(analyzer.get_lists_for_pdf()) txt.extend(analyzer.get_txt_for_pdf()) - return graphs_and_titles, dataframes, txt + return graphs_and_titles, dataframes, lists, txt diff --git a/plugins/ufm_log_analyzer_plugin/src/loganalyze/pdf_creator.py b/plugins/ufm_log_analyzer_plugin/src/loganalyze/pdf_creator.py index 01d0a55d..0bb56f3e 100644 --- a/plugins/ufm_log_analyzer_plugin/src/loganalyze/pdf_creator.py +++ b/plugins/ufm_log_analyzer_plugin/src/loganalyze/pdf_creator.py @@ -22,12 +22,12 @@ class PDFCreator(FPDF): - def __init__(self, pdf_path, pdf_header, images_path, fabric_stats_list): + def __init__(self, pdf_path, pdf_header, images_path, txt_list): super().__init__() self._pdf_path = pdf_path self._pdf_header = pdf_header self._images_path = images_path - self._fabric_stats_list = fabric_stats_list + self._txt_list = txt_list def header(self): self.set_font("Arial", "B", 12) @@ -60,7 +60,8 @@ def add_images(self): def add_text(self): self.set_font("Arial", "", 12) output = StringIO() - print(self._fabric_stats_list, file=output) + for txt in self._txt_list: + print(txt, file=output) text = output.getvalue().strip() self.multi_cell(0, 10, text) From 6369ea11900baa9c98d2e1d4360e655061414489 Mon Sep 17 00:00:00 2001 From: Miryam Schwartz Date: Thu, 5 Dec 2024 17:26:53 +0200 Subject: [PATCH 4/5] fix ruff and pylint comments --- .../ufm_log_analyzer_plugin/src/loganalyze/log_analyzer.py | 3 --- .../src/loganalyze/log_analyzers/base_analyzer.py | 2 +- .../src/loganalyze/log_analyzers/console_log_analyzer.py | 2 +- .../log_analyzers/ibdiagnet2_port_counters_analyzer.py | 5 +++-- 4 files changed, 5 insertions(+), 7 deletions(-) diff --git a/plugins/ufm_log_analyzer_plugin/src/loganalyze/log_analyzer.py b/plugins/ufm_log_analyzer_plugin/src/loganalyze/log_analyzer.py index 15422650..90cdabea 100755 --- a/plugins/ufm_log_analyzer_plugin/src/loganalyze/log_analyzer.py +++ b/plugins/ufm_log_analyzer_plugin/src/loganalyze/log_analyzer.py @@ -28,9 +28,6 @@ import traceback from typing import Callable, List, Set, Tuple -from numpy import extract - - from loganalyze.log_analyzers.base_analyzer import BaseImageCreator from loganalyze.logs_extraction.directory_extractor import DirectoryExtractor from loganalyze.log_analyzers.ufm_top_analyzer import UFMTopAnalyzer diff --git a/plugins/ufm_log_analyzer_plugin/src/loganalyze/log_analyzers/base_analyzer.py b/plugins/ufm_log_analyzer_plugin/src/loganalyze/log_analyzers/base_analyzer.py index a20d6221..4b107878 100644 --- a/plugins/ufm_log_analyzer_plugin/src/loganalyze/log_analyzers/base_analyzer.py +++ b/plugins/ufm_log_analyzer_plugin/src/loganalyze/log_analyzers/base_analyzer.py @@ -166,7 +166,7 @@ def get_images_created(self): def get_dataframes_for_pdf(self): return self._dataframes_for_pdf - + def get_lists_for_pdf(self): return self._lists_for_pdf diff --git a/plugins/ufm_log_analyzer_plugin/src/loganalyze/log_analyzers/console_log_analyzer.py b/plugins/ufm_log_analyzer_plugin/src/loganalyze/log_analyzers/console_log_analyzer.py index 9b34ec99..8d0dccf5 100644 --- a/plugins/ufm_log_analyzer_plugin/src/loganalyze/log_analyzers/console_log_analyzer.py +++ b/plugins/ufm_log_analyzer_plugin/src/loganalyze/log_analyzers/console_log_analyzer.py @@ -107,7 +107,7 @@ def print_exceptions_per_time_count(self): "Time", "Amount of exceptions", "Exceptions count", - ) + ) def save_ufm_versions(self): self._txt_for_pdf.append( diff --git a/plugins/ufm_log_analyzer_plugin/src/loganalyze/log_analyzers/ibdiagnet2_port_counters_analyzer.py b/plugins/ufm_log_analyzer_plugin/src/loganalyze/log_analyzers/ibdiagnet2_port_counters_analyzer.py index 3f37912d..c617fbf0 100644 --- a/plugins/ufm_log_analyzer_plugin/src/loganalyze/log_analyzers/ibdiagnet2_port_counters_analyzer.py +++ b/plugins/ufm_log_analyzer_plugin/src/loganalyze/log_analyzers/ibdiagnet2_port_counters_analyzer.py @@ -42,7 +42,7 @@ def __init__( self.save_number_of_core_dumps, self.save_collectx_versions, } - + # Based on the log path, decided if this is primary or secondary if "ufm_logs" in logs_csvs[0]: self.telemetry_type = "primary" @@ -59,7 +59,8 @@ def save_collectx_versions(self): self._log_data_sorted["type"] == "collectx_version" ]["data"].unique() self._txt_for_pdf.append( - f"collectx versions found in {self.telemetry_type} telemetry log {set(unique_collectx_versions)}" + f"collectx versions found in {self.telemetry_type} telemetry log \ + {set(unique_collectx_versions)}" ) def save_number_of_switches_and_ports(self): From e15a9bf0d736c3af0aaf685ea3feb2674558ba1b Mon Sep 17 00:00:00 2001 From: Miryam Schwartz Date: Thu, 5 Dec 2024 17:29:02 +0200 Subject: [PATCH 5/5] fix ruff and pylint comments --- .../log_analyzers/ibdiagnet2_port_counters_analyzer.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/ufm_log_analyzer_plugin/src/loganalyze/log_analyzers/ibdiagnet2_port_counters_analyzer.py b/plugins/ufm_log_analyzer_plugin/src/loganalyze/log_analyzers/ibdiagnet2_port_counters_analyzer.py index c617fbf0..75ef9e28 100644 --- a/plugins/ufm_log_analyzer_plugin/src/loganalyze/log_analyzers/ibdiagnet2_port_counters_analyzer.py +++ b/plugins/ufm_log_analyzer_plugin/src/loganalyze/log_analyzers/ibdiagnet2_port_counters_analyzer.py @@ -59,7 +59,7 @@ def save_collectx_versions(self): self._log_data_sorted["type"] == "collectx_version" ]["data"].unique() self._txt_for_pdf.append( - f"collectx versions found in {self.telemetry_type} telemetry log \ + f"collectx versions found in {self.telemetry_type} telemetry log \ {set(unique_collectx_versions)}" )