From 696daa6ec1a0baf378ac75acdb2b2d988d373b8e Mon Sep 17 00:00:00 2001 From: Christophe Vandeplas Date: Wed, 4 Sep 2024 21:29:20 +0200 Subject: [PATCH] fix: [spindumpnosymbols] fix for zombie processes --- parsers/spindumpnosymbols.py | 5 ++++- utils/base.py | 1 + 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/parsers/spindumpnosymbols.py b/parsers/spindumpnosymbols.py index f0c1d29..341954a 100644 --- a/parsers/spindumpnosymbols.py +++ b/parsers/spindumpnosymbols.py @@ -91,7 +91,10 @@ def parse_processes(data: list, start_timestamp: int) -> list[dict]: if "Process:" in line.strip(): if not init: process = SpindumpNoSymbolsParser.parse_process(process_buffer) - timestamp = start_time - timedelta(seconds=int(process['Time Since Fork'].rstrip('s'))) + try: + timestamp = start_time - timedelta(seconds=int(process['Time Since Fork'].rstrip('s'))) + except KeyError: # some don't have a time since fork, like zombie processes + timestamp = start_time process['timestamp'] = timestamp.timestamp() process['datetime'] = timestamp.isoformat() processes.append(process) diff --git a/utils/base.py b/utils/base.py index a0dbf3b..ad5b8f2 100644 --- a/utils/base.py +++ b/utils/base.py @@ -46,6 +46,7 @@ def __init__(self, module_filename: str, config: SysdiagnoseConfig, case_id: str self.case_data_folder = config.get_case_data_folder(case_id) self.case_data_subfolder = os.path.join(self.case_data_folder, os.listdir(self.case_data_folder)[0]) self.case_parsed_data_folder = config.get_case_parsed_data_folder(case_id) + os.makedirs(self.case_parsed_data_folder, exist_ok=True) if not os.path.isdir(self.case_data_folder): print(f"Case {case_id} does not exist", file=sys.stderr)