From 9fe103233eaee965849c00c66c1b352f31932e01 Mon Sep 17 00:00:00 2001 From: Mingxin Liu Date: Mon, 20 Feb 2017 14:36:02 +0800 Subject: [PATCH] mon/OSDMonitor: fix deviding by zero in OSDUtilizationDumper Signed-off-by: Mingxin Liu --- src/mon/OSDMonitor.cc | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/mon/OSDMonitor.cc b/src/mon/OSDMonitor.cc index fae5b876d7b..45bf6db94c2 100644 --- a/src/mon/OSDMonitor.cc +++ b/src/mon/OSDMonitor.cc @@ -641,7 +641,9 @@ protected: int64_t kb = 0, kb_used = 0, kb_avail = 0; double util = 0; if (get_bucket_utilization(qi.id, &kb, &kb_used, &kb_avail)) - util = 100.0 * (double)kb_used / (double)kb; + if (kb_used && kb) + util = 100.0 * (double)kb_used / (double)kb; + double var = 1.0; if (average_util) var = util / average_util;