[checkmk-commits] Check_MK Git: check_mk: #1985 FIX PNP graph dashlet handles graphs in distributed setups correctly

Lars Michelsen lm at mathias-kettner.de
Wed Feb 18 11:41:15 CET 2015


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

Author: Lars Michelsen <lm at mathias-kettner.de>
Date:   Wed Feb 18 11:41:08 2015 +0100

#1985 FIX PNP graph dashlet handles graphs in distributed setups correctly

The PNP graph dashlet now automatically detects the site a host is located
on and shows the PNP graph from this site.

---

 .werks/1985                       |   11 +++++++++++
 ChangeLog                         |    1 +
 web/plugins/dashboard/dashlets.py |   16 ++++++++++++++--
 3 files changed, 26 insertions(+), 2 deletions(-)

diff --git a/.werks/1985 b/.werks/1985
new file mode 100644
index 0000000..e346eba
--- /dev/null
+++ b/.werks/1985
@@ -0,0 +1,11 @@
+Title: PNP graph dashlet handles graphs in distributed setups correctly
+Level: 1
+Component: multisite
+Class: fix
+Compatible: compat
+State: unknown
+Version: 1.2.7i1
+Date: 1424255974
+
+The PNP graph dashlet now automatically detects the site a host is located
+on and shows the PNP graph from this site.
diff --git a/ChangeLog b/ChangeLog
index 1b3c767..e733719 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -201,6 +201,7 @@
     * 1981 FIX: Not trying to render view in view editor when the view is not valid
     * 1983 FIX: Fixed special case in language configuration via user profile...
     * 1984 FIX: Fixed loosing sidebar after switching to/from edit mode in dashboard edior on page reload...
+    * 1985 FIX: PNP graph dashlet handles graphs in distributed setups correctly...
 
     WATO:
     * 1760 Added search form to manual checks page
diff --git a/web/plugins/dashboard/dashlets.py b/web/plugins/dashboard/dashlets.py
index 28d0640..62b413e 100644
--- a/web/plugins/dashboard/dashlets.py
+++ b/web/plugins/dashboard/dashlets.py
@@ -324,17 +324,29 @@ if (has_canvas_support()) {
 #   '----------------------------------------------------------------------'
 
 def make_pnp_url(dashlet, what):
-    if not dashlet['context'].get('host'):
+    host = dashlet['context'].get('host')
+    if not host:
         raise MKUserError('host', _('Missing needed host parameter.'))
+
     service = dashlet['context'].get('service')
     if not service:
         service = "_HOST_"
 
-    site = html.var('site')
+    # When the site is available via URL context, use it. Otherwise it is needed
+    # to check all sites for the requested host
+    if html.has_var('site'):
+        site = html.var('site')
+    else:
+        html.live.set_prepend_site(True)
+        query = "GET hosts\nFilter: name = %s\nColumns: name" % lqencode(host)
+        site = html.live.query_column(query)[0]
+        html.live.set_prepend_site(False)
+
     if not site:
         base_url = defaults.url_prefix
     else:
         base_url = html.site_status[site]["site"]["url_prefix"]
+
     base_url += "pnp4nagios/index.php/"
     var_part = "?host=%s&srv=%s&source=%d&view=%s&theme=multisite" % \
             (pnp_cleanup(dashlet['context']['host']), pnp_cleanup(service),



More information about the checkmk-commits mailing list