Set average to zero when no statistics are returned
Sapan Bhatia [Sat, 10 Jan 2015 04:55:54 +0000 (04:55 +0000)]
planetstack/openstack_observer/ceilometer.py

index 6875ae8..00c1238 100644 (file)
@@ -77,7 +77,10 @@ def meters_to_stats(meters):
         stats['average']+=m.sum
         stats['unit'] = 'ns'
 
-    stats['average']/=len(meters)
+    if (len(meters)):
+        stats['average']/=len(meters)
+    else:
+        stats['average']=0
     return stats