aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorVolker Hoffmann <volker@cheleb.net>2016-11-01 07:37:26 +0100
committerVolker Hoffmann <volker@cheleb.net>2016-11-01 07:37:26 +0100
commitfc9f044a650f71f5b8dbcfc6b5130ad60e3c5222 (patch)
tree77bfc7bf55a820b0ab14525292cd4912274c58f5
parent7758555e9af196358e41e2b5622ba3cd42a15d8f (diff)
fix: all nodes down cause divide by zero
-rw-r--r--Common/derived.py28
1 files changed, 21 insertions, 7 deletions
diff --git a/Common/derived.py b/Common/derived.py
index f1d2edd..65ecde9 100644
--- a/Common/derived.py
+++ b/Common/derived.py
@@ -23,26 +23,40 @@ def compute_utilization(number_of_nodes_down, \
total_cpu_cores = 16*192
cpu_nodes_down = number_of_nodes_down['cpu']*16
allocated_cpu_cores = number_of_allocated_cpus['cpu']
- utilization['cpu'] = \
- float(allocated_cpu_cores) / float(total_cpu_cores - cpu_nodes_down)
+ if float(total_cpu_cores - cpu_nodes_down) > 0.0:
+ utilization['cpu'] = \
+ float(allocated_cpu_cores) / float(total_cpu_cores - \
+ cpu_nodes_down)
+ else:
+ utilization['cpu'] = 0.0
# Tasna Utilization
# 4 GTX 590 Boards per Server, 2 GPUs per Board, 5 Servers = 40 Slots
total_tasna_slots = 40 - number_of_nodes_down['tasna'] * 8
allocated_tasna_slots = number_of_jobs_by_partition['tasna']['running']
- utilization['tasna'] = \
- float(allocated_tasna_slots) / float(total_tasna_slots)
+ if float(total_tasna_slots) > 0.0:
+ utilization['tasna'] = \
+ float(allocated_tasna_slots) / float(total_tasna_slots)
+ else:
+ utilization['tasna'] = 0.0
# Vesta Utilization
# 8 K80 Boards per Server, 2 GPUs per Board, 2 Servers = 32 Slots
total_vesta_slots = 32 - number_of_nodes_down['vesta'] * 16
allocated_vesta_slots = number_of_jobs_by_partition['vesta']['running']
- utilization['vesta'] = \
- float(allocated_vesta_slots) / float(total_vesta_slots)
+ if float(total_vesta_slots) > 0.0:
+ utilization['vesta'] = \
+ float(allocated_vesta_slots) / float(total_vesta_slots)
+ else:
+ utilization['vesta'] = 0.0
# GPU Utilization
total_gpu_slots = total_tasna_slots + total_vesta_slots
allocated_gpu_slots = allocated_tasna_slots + allocated_vesta_slots
- utilization['gpu'] = float(allocated_gpu_slots) / float(total_gpu_slots)
+ if float(total_gpu_slots) > 0.0:
+ utilization['gpu'] = \
+ float(allocated_gpu_slots) / float(total_gpu_slots)
+ else:
+ utilization['gpu'] = 0.0
return utilization