Livestatus avg Stats returning sum
chaen opened this issue · comments
Hi,
when you make a request with livestatus for the average of something (e.g. Get services\nStats: avg latency), you get back the sum and not the avg. Copy-and-paste I assume ^^
Here's the fix
diff --git a/bad/modules/livestatus_broker/livestatus_query.py b/good/modules/livestatus_broker/livestatus_query.py
index becabab..5bf7432 100644
--- a/bad/modules/livestatus_broker/livestatus_query.py
+++ b/good/modules/livestatus_broker/livestatus_query.py
@@ -835,7 +835,7 @@ class LiveStatusQuery(object):
def avg_postproc(item):
if item != []:
return sum(float(getattr(obj, attribute)(self)) for obj in item)
return (sum(float(getattr(obj, attribute)(self)) for obj in item) / len(item) )
return 0
def std_postproc(item):
Original ticket : shinken-solutions/shinken#990
Hi, I am encountering the issue myself. The fix seems legit.