From 06706bea9339e26d1a0ab395e9d42d391ee8c03c Mon Sep 17 00:00:00 2001 From: John Spray Date: Sat, 23 Sep 2017 15:18:18 +0100 Subject: [PATCH] mgr/zabbix: fix div by zero Fixes: http://tracker.ceph.com/issues/21518 Signed-off-by: John Spray (cherry picked from commit 9c02738b4ea0303f5b3cbfc4748d6791007be834) --- src/pybind/mgr/zabbix/module.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/pybind/mgr/zabbix/module.py b/src/pybind/mgr/zabbix/module.py index eb2eba11a1ffe..a7baac1ba6900 100644 --- a/src/pybind/mgr/zabbix/module.py +++ b/src/pybind/mgr/zabbix/module.py @@ -12,7 +12,10 @@ from mgr_module import MgrModule def avg(data): - return sum(data) / float(len(data)) + if len(data): + return sum(data) / float(len(data)) + else: + return 0 class ZabbixSender(object): -- 2.39.5