From dae5055c67ccf0577c740b4fd829bd5f0c1bf02e Mon Sep 17 00:00:00 2001 From: Tom Morris Date: Wed, 4 Jan 2017 20:28:15 -0500 Subject: [PATCH] 10472: add latent support for rolled up stats --- .../crunchstat_summary/summarizer.py | 39 ++++++++++++------- 1 file changed, 24 insertions(+), 15 deletions(-) diff --git a/tools/crunchstat-summary/crunchstat_summary/summarizer.py b/tools/crunchstat-summary/crunchstat_summary/summarizer.py index 8e601e9f13..f1c97c282c 100644 --- a/tools/crunchstat-summary/crunchstat_summary/summarizer.py +++ b/tools/crunchstat-summary/crunchstat_summary/summarizer.py @@ -60,6 +60,21 @@ class Summarizer(object): logger.debug("%s: logdata %s", self.label, logdata) + def run_child(self, uuid): + if self._skip_child_jobs: + logger.warning('%s: omitting stats from child job %s' + ' because --skip-child-jobs flag is on', + self.label, uuid) + return + logger.debug('%s: follow %s', self.label, uuid) + child_summarizer = JobSummarizer(uuid) + child_summarizer.stats_max = self.stats_max + child_summarizer.task_stats = self.task_stats + child_summarizer.tasks = self.tasks + child_summarizer.starttime = self.starttime + child_summarizer.run() + logger.debug('%s: done %s', self.label, uuid) + def run(self): logger.debug("%s: parsing logdata %s", self.label, self._logdata) for line in self._logdata: @@ -80,22 +95,11 @@ class Summarizer(object): self.stats_max['time']['elapsed'] = elapsed continue + # Old style job logs only - newer style uses job['components'] + uuid = None m = re.search(r'^\S+ \S+ \d+ (?P\d+) stderr Queued job (?P\S+)$', line) if m: - uuid = m.group('uuid') - if self._skip_child_jobs: - logger.warning('%s: omitting stats from child job %s' - ' because --skip-child-jobs flag is on', - self.label, uuid) - continue - logger.debug('%s: follow %s', self.label, uuid) - child_summarizer = JobSummarizer(uuid) - child_summarizer.stats_max = self.stats_max - child_summarizer.task_stats = self.task_stats - child_summarizer.tasks = self.tasks - child_summarizer.starttime = self.starttime - child_summarizer.run() - logger.debug('%s: done %s', self.label, uuid) + self.run_child(m.group('uuid')) continue m = re.search(r'^(?P[^\s.]+)(\.\d+)? (?P\S+) \d+ (?P\d+) stderr crunchstat: (?P\S+) (?P.*?)( -- interval (?P.*))?\n', line) @@ -178,7 +182,12 @@ class Summarizer(object): self.stats_max[category][stat] = val except Exception as e: logger.info('Skipping malformed line: {}Error was: {}\n'.format(line, e)) - logger.debug('%s: done parsing', self.label) + logger.debug('%s: done parsing log', self.label) + + # Enabling this will roll up stats for all subjobs into the parent job + if False and 'components' in self.job: + for cname, component in self.job['components'].iteritems(): + self.run_child(component) self.job_tot = collections.defaultdict( functools.partial(collections.defaultdict, int)) -- 2.30.2