Skip to content
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
24 changes: 14 additions & 10 deletions bm-runner/monitors/sys_stats.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,10 +37,13 @@ def stop(self):
# This acts like ctrl+C
self.process.send_signal(signal.SIGINT)

# TODO: try catch and error handling
def read_output(self) -> dict:
with open(self.fname, "r") as f:
return json.load(f)
def read_output(self) -> Optional[dict]:
try:
with open(self.fname, "r") as f:
return json.load(f)
except (FileNotFoundError, json.JSONDecodeError) as e:
bm_log(f"Could not read mpstat JSON from {self.fname}: {e}")
return None


class SystemStats(Monitor):
Expand Down Expand Up @@ -107,16 +110,17 @@ def get_soft_interrupts(self, data):
def collect_results(self) -> str:
if self.stat:
data = self.stat.read_output()
self.dump_plot(data)
results = self.get_cpu_load(data)
results += self.get_sum_interrupts(data)
results += self.get_soft_interrupts(data)
return results
if data:
self.dump_plot(data)
results = self.get_cpu_load(data)
results += self.get_sum_interrupts(data)
results += self.get_soft_interrupts(data)
return results
else:
bm_log(
"Could not read output of sys stats, `self.stat` is not initialized!", LogType.ERROR
)
return ""
return ""

# TODO: decide if the generate should stay here, and if it should be part of the final html
def dump_plot(self, data):
Expand Down
Loading