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..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,7 +28,6 @@ import traceback from typing import Callable, List, Set, Tuple - 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 @@ -369,7 +368,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 +384,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..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 @@ -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() @@ -166,6 +167,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..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 @@ -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): @@ -106,6 +109,11 @@ def print_exceptions_per_time_count(self): "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): super().full_analysis() self.print_exceptions() 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 47b6ccc5..688ecfb9 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,9 @@ 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]: self.telemetry_type = "primary" @@ -52,11 +54,14 @@ 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._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): """ @@ -217,7 +222,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)