Module: check_mk
Branch: master
Commit: 203d93c582d01294a3fa445a7542401f2e095d1a
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=203d93c582d012…
Author: Lars Michelsen <lm(a)mathias-kettner.de>
Date: Tue Jun 20 14:55:07 2017 +0200
Extension to #4761: Suppress MKLivestatusTableNotFoundError() by default
Change-Id: If3e5ff659e39dd77e08c4794e2640c34c9b08080
---
livestatus/api/python/livestatus.py | 10 ++++++++--
web/plugins/sidebar/shipped.py | 13 +------------
2 files changed, 9 insertions(+), 14 deletions(-)
diff --git a/livestatus/api/python/livestatus.py b/livestatus/api/python/livestatus.py
index 7352ca4..ddb1d09 100644
--- a/livestatus/api/python/livestatus.py
+++ b/livestatus/api/python/livestatus.py
@@ -182,11 +182,17 @@ class Query(object):
query. The object can be used to hand over the handling code some flags, for
example to influence the error handling during query processing."""
+ default_suppressed_exceptions = [MKLivestatusTableNotFoundError]
+
def __init__(self, query, suppress_exceptions=None):
super(Query, self).__init__()
self._query = self._ensure_unicode(query)
- self.suppress_exceptions = suppress_exceptions or []
+
+ if suppress_exceptions == None:
+ self.suppress_exceptions = self.default_suppressed_exceptions
+ else:
+ self.suppress_exceptions = suppress_exceptions
def _ensure_unicode(self, thing):
@@ -743,7 +749,7 @@ class MultiSiteConnection(Helpers):
if isinstance(query, Query):
suppress_exceptions = tuple(query.suppress_exceptions)
else:
- suppress_exceptions = tuple()
+ suppress_exceptions = tuple(Query.default_suppressed_exceptions)
# Then retrieve all answers. We will be as slow as the slowest of all
# connections.
diff --git a/web/plugins/sidebar/shipped.py b/web/plugins/sidebar/shipped.py
index c93ddd2..4bf3e13 100644
--- a/web/plugins/sidebar/shipped.py
+++ b/web/plugins/sidebar/shipped.py
@@ -637,20 +637,9 @@ def get_tactical_overview_data(extra_filter_headers):
stat_only=True,
extra_headers=extra_filter_headers)
- # Livestatus < 1.4.0 does not know this table. The API will raise a
- # MKLivestatusTableNotFoundError exception in this case which will mark
- # the site as dead by default. Adding the exception to the list of
- # suppressed exception makes livestatus silently ignore this kind of
- # error. This makes it possible to make livestatus connections with
- # older Check_MK versions.
- query = livestatus.Query(
- event_query,
- suppress_exceptions=[livestatus.MKLivestatusTableNotFoundError],
- )
-
try:
sites.live().set_auth_domain("ec")
- event_data = sites.live().query_summed_stats(query)
+ event_data = sites.live().query_summed_stats(event_query)
except livestatus.MKLivestatusNotFoundError:
event_data = [0, 0, 0]
finally: