[checkmk-commits] Check_MK Git: check_mk: #2177 FIX Host/ Service statistics dashlets honor the site filter correctly now

Lars Michelsen lm at mathias-kettner.de
Tue Apr 14 09:12:40 CEST 2015


Module: check_mk
Branch: master
Commit: 593a53b371c8b72238c7be49b18b6fef5a9b880e
URL:    http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=593a53b371c8b72238c7be49b18b6fef5a9b880e

Author: Lars Michelsen <lm at mathias-kettner.de>
Date:   Tue Apr 14 09:12:34 2015 +0200

#2177 FIX Host/Service statistics dashlets honor the site filter correctly now

---

 .werks/2177                       |   10 ++++++++++
 ChangeLog                         |    1 +
 web/plugins/dashboard/dashlets.py |   13 ++++++++++---
 3 files changed, 21 insertions(+), 3 deletions(-)

diff --git a/.werks/2177 b/.werks/2177
new file mode 100644
index 0000000..0ca4a13
--- /dev/null
+++ b/.werks/2177
@@ -0,0 +1,10 @@
+Title: Host/Service statistics dashlets honor the site filter correctly now
+Level: 1
+Component: multisite
+Class: fix
+Compatible: compat
+State: unknown
+Version: 1.2.7i1
+Date: 1428995529
+
+
diff --git a/ChangeLog b/ChangeLog
index 90a6501..aa16b2c 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -384,6 +384,7 @@
     * 2141 FIX: Fix computation of explicit time ranges with time of day...
     * 2142 FIX: Fix non-working option for disabling column headers in grouped boxed views...
     * 2168 FIX: Fixed automation actions with transid=-1 when using basic authentication
+    * 2177 FIX: Host/Service statistics dashlets honor the site filter correctly now
 
     WATO:
     * 1760 Added search form to manual checks page
diff --git a/web/plugins/dashboard/dashlets.py b/web/plugins/dashboard/dashlets.py
index 2cbad09..ee74711 100644
--- a/web/plugins/dashboard/dashlets.py
+++ b/web/plugins/dashboard/dashlets.py
@@ -203,7 +203,6 @@ dashlet_types["servicestats"] = {
 }
 
 def render_statistics(pie_id, what, table, filter, dashlet):
-    html.write("<div class=stats>")
     pie_diameter     = 130
     pie_left_aspect  = 0.5
     pie_right_aspect = 0.8
@@ -211,7 +210,7 @@ def render_statistics(pie_id, what, table, filter, dashlet):
     info = what == 'hosts' and 'host' or 'service'
     use_filters = visuals.filters_of_visual(dashlet, [info])
     for filt in use_filters:
-        if filt.available():
+        if filt.available() and not isinstance(filt, visuals.FilterSite):
             filter += filt.filter(info)
 
     query = "GET %s\n" % what
@@ -219,10 +218,18 @@ def render_statistics(pie_id, what, table, filter, dashlet):
         query += entry[3]
     query += filter
 
-    result = html.live.query_summed_stats(query)
+    site = dashlet['context'].get('siteopt', {}).get('site')
+    if site:
+        html.live.set_only_sites([site])
+        result = html.live.query_row(query)
+        html.live.set_only_sites()
+    else:
+        result = html.live.query_summed_stats(query)
+
     pies = zip(table, result)
     total = sum([x[1] for x in pies])
 
+    html.write("<div class=stats>")
     html.write('<canvas class=pie width=%d height=%d id="%s_stats" style="float: left"></canvas>' %
             (pie_diameter, pie_diameter, pie_id))
     html.write('<img src="images/globe.png" class="globe">')



More information about the checkmk-commits mailing list