diff --git a/slurm-eff-tool.py b/slurm-eff-tool.py index d62b88c..b340f17 100755 --- a/slurm-eff-tool.py +++ b/slurm-eff-tool.py @@ -831,7 +831,11 @@ def make_single_row(rec: JobRecord, dflt_mpcpu: float) -> OutputRow: waste_cpu = None if rec.cpu_eff is not None: - waste_cpu = walltime * (100-rec.cpu_eff) * rec.cpus + # We count failed jobs as wasted CPU! + if rec.state != state_mappings['COMPLETED']: + waste_cpu = walltime * rec.cpus + else: + waste_cpu = walltime * (100-rec.cpu_eff)/100 * rec.cpus jobid = rec.jobidraw if jobid == "": @@ -897,7 +901,11 @@ def make_aggregate_row(records: list[JobRecord], username: str, waste_cpu=None if cpu_efficiency is not None and walltime is not None: - waste_cpu = count * walltime * (100-cpu_efficiency) * first.cpus + # We count failed jobs as wasted CPU! + if first.state != state_mappings['COMPLETED']: + waste_cpu = count * walltime * first.cpus + else: + waste_cpu = count * walltime * (100-cpu_efficiency)/100 * first.cpus return OutputRow( username=username,