Module: check_mk
Branch: master
Commit: 53b59e0f1d773b1825976c5d03745309774ce73b
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=53b59e0f1d773b…
Author: Lars Michelsen <lm(a)mathias-kettner.de>
Date: Thu Sep 20 11:37:37 2012 +0200
FIX: Fixed bug in alert statistics view (only last 1000 lines were
processed for calculating the statistics)
---
ChangeLog | 2 ++
web/htdocs/views.py | 12 ++++++++++--
web/plugins/views/datasources.py | 18 +++++++++++-------
3 files changed, 23 insertions(+), 9 deletions(-)
diff --git a/ChangeLog b/ChangeLog
index 2be65c2..ac516c9 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -129,6 +129,8 @@
* FIX: Removed duplicate url parameters e.g. in dashboard (display_options)
* FIX: Dashboard: If original request showed no "max rows"-message, the
page rendered during reload does not show the message anymore
+ * FIX: Fixed bug in alert statistics view (only last 1000 lines were
+ processed for calculating the statistics)
Livecheck:
* FIX: Compile livecheck also if diet libc is missing
diff --git a/web/htdocs/views.py b/web/htdocs/views.py
index efddf44..502866f 100644
--- a/web/htdocs/views.py
+++ b/web/htdocs/views.py
@@ -1228,6 +1228,14 @@ def show_view(view, show_heading = False, show_buttons = True,
colset.remove("site")
columns = list(colset)
+ # We had a problem with stats queries on the logtable where
+ # the limit was not applied on the resulting rows but on the
+ # lines of the log processed. This resulted in wrong stats.
+ # For these datasources we ignore the query limits.
+ limit = None
+ if not datasource.get('ignore_limit', False):
+ limit = get_limit()
+
# Get list of painter options we need to display (such as PNP time range
# or the format being used for timestamp display)
painter_options = []
@@ -1246,9 +1254,9 @@ def show_view(view, show_heading = False, show_buttons = True,
# In that case that function is used to compute the result.
if type(tablename) == type(lambda x:None):
- rows = tablename(columns, query, only_sites, get_limit(),
all_active_filters)
+ rows = tablename(columns, query, only_sites, limit, all_active_filters)
else:
- rows = query_data(datasource, columns, add_columns, query, only_sites,
get_limit())
+ rows = query_data(datasource, columns, add_columns, query, only_sites,
limit)
# Now add join information, if there are join columns
if len(join_painters) > 0:
diff --git a/web/plugins/views/datasources.py b/web/plugins/views/datasources.py
index 1357c39..8755312 100644
--- a/web/plugins/views/datasources.py
+++ b/web/plugins/views/datasources.py
@@ -35,6 +35,9 @@
# idkeys: these are used to generate a key which is uniq for each data row
+# ignore_limit: Ignore the soft/hard query limits in view.py/query_data(). This
+# fixes stats queries on e.g. the log table.
+
multisite_datasources["hosts"] = {
"title" : _("All hosts"),
"table" : "hosts",
@@ -155,11 +158,12 @@ multisite_datasources["log_host_events"] = {
}
multisite_datasources["alert_stats"] = {
- "title" : _("Alert Statistics"),
- "table" : "log",
- "add_headers" : "Filter: class = 1\nStats: state = 0\nStats: state =
1\nStats: state = 2\nStats: state = 3\nStats: state != 0\n",
- "add_columns" : [ "alerts_ok", "alerts_warn",
"alerts_crit", "alerts_unknown", "alerts_problem" ],
- "infos" : [ "log", "host", "service",
"contact", "command" ],
- "keys" : [],
- "idkeys" : [ 'host_name', 'service_description' ],
+ "title" : _("Alert Statistics"),
+ "table" : "log",
+ "add_headers" : "Filter: class = 1\nStats: state = 0\nStats: state =
1\nStats: state = 2\nStats: state = 3\nStats: state != 0\n",
+ "add_columns" : [ "alerts_ok", "alerts_warn",
"alerts_crit", "alerts_unknown", "alerts_problem" ],
+ "infos" : [ "log", "host", "service",
"contact", "command" ],
+ "keys" : [],
+ "idkeys" : [ 'host_name', 'service_description' ],
+ "ignore_limit" : True,
}