Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Livestatus avg Stats returning sum #8

Open
chaen opened this issue Dec 4, 2013 · 1 comment
Open

Livestatus avg Stats returning sum #8

chaen opened this issue Dec 4, 2013 · 1 comment

Comments

@chaen
Copy link

chaen commented Dec 4, 2013

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

@ypsah
Copy link

ypsah commented Aug 4, 2015

Hi, I am encountering the issue myself. The fix seems legit.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants