Module: check_mk
Branch: master
Commit: 165a09fb5f9f769a0b5343c7cf51907b49300e88
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=165a09fb5f9f76…
Author: Lars Michelsen <lm(a)mathias-kettner.de>
Date: Tue Apr 21 10:49:26 2015 +0200
Improved handling of graph hover when distributed site is not reachable
---
web/htdocs/check_mk.css | 5 +++++
web/htdocs/js/checkmk.js | 2 +-
web/htdocs/livestatus.py | 6 +++++-
web/htdocs/metrics.py | 8 +++++++-
4 files changed, 18 insertions(+), 3 deletions(-)
diff --git a/web/htdocs/check_mk.css b/web/htdocs/check_mk.css
index 88674a7..80349a2 100644
--- a/web/htdocs/check_mk.css
+++ b/web/htdocs/check_mk.css
@@ -553,3 +553,8 @@ div#hover_menu {
z-index: 40;
color: #000;
}
+
+div#hover_menu div.error {
+ width:350px;
+ margin: 0;
+}
diff --git a/web/htdocs/js/checkmk.js b/web/htdocs/js/checkmk.js
index 43f6dd2..28a905c 100644
--- a/web/htdocs/js/checkmk.js
+++ b/web/htdocs/js/checkmk.js
@@ -812,7 +812,7 @@ function hover_graph(site, host_name, service)
// the expected code, simply display an error message.
if (c.indexOf('/image?') === -1) {
// Error! unexpected response
- c = '<div
style="background-color:#BA2C2C;width:350px;padding:5px"> '
+ c = '<div class="error"> '
+ 'ERROR: Received an unexpected response '
+ 'while trying to display the PNP-Graphs. Maybe there is a problem
with the '
+ 'authentication.</div>';
diff --git a/web/htdocs/livestatus.py b/web/htdocs/livestatus.py
index cc67c40..562345f 100644
--- a/web/htdocs/livestatus.py
+++ b/web/htdocs/livestatus.py
@@ -109,7 +109,11 @@ class Helpers:
def query_row(self, query):
"""Issues a query that returns one line of data and returns the
elements
of that line as list"""
- return self.query(query, "ColumnHeaders: off\n")[0]
+ result = self.query(query, "ColumnHeaders: off\n")
+ try:
+ return result[0]
+ except IndexError:
+ raise MKLivestatusNotFoundError(query)
def query_row_assoc(self, query):
"""Issues a query that returns one line of data and returns the
elements
diff --git a/web/htdocs/metrics.py b/web/htdocs/metrics.py
index e1a17d3..ab1f578 100644
--- a/web/htdocs/metrics.py
+++ b/web/htdocs/metrics.py
@@ -37,6 +37,7 @@
import math, time
import config, defaults
from lib import *
+import livestatus
# Datastructures and functions needed before plugins can be loaded
loaded_with_language = False
@@ -957,7 +958,12 @@ def page_show_graph():
"Columns: perf_data metrics check_command\n" % (host_name,
service)
html.live.set_only_sites([site])
- data = html.live.query_row(query)
+ try:
+ data = html.live.query_row(query)
+ except livestatus.MKLivestatusNotFoundError:
+ html.write('<div class="error">%s</div>' %
+ _('Failed to fetch data for graph. Maybe the site is not
reachable?'))
+ return
html.live.set_only_sites(None)
if service == "_HOST_":