Module: check_mk
Branch: master
Commit: 827cd9ba2910673851da574a9f6a3e1a1075dd54
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=827cd9ba291067…
Author: Mathias Kettner <mk(a)mathias-kettner.de>
Date: Tue Dec 20 15:32:23 2016 +0100
4200 FIX Fix computation of Event Console performance snapin in distributed mode
This contents of the sidebar snapin {{Event Console Performance}} showed invalid
data in case of a multi-sited distributed Event Console: It only show data from
one random instance. This has been fixed.
Change-Id: I6738f97f6bbebebc9ba1130be4d2c0e155f33eee
---
.werks/4200 | 11 +++++++
ChangeLog | 1 +
web/htdocs/mkeventd.py | 64 +++++++++++++++++++++++++++++++++++------
web/plugins/sidebar/mkeventd.py | 11 +++++--
4 files changed, 76 insertions(+), 11 deletions(-)
diff --git a/.werks/4200 b/.werks/4200
new file mode 100644
index 0000000..be0c6fc
--- /dev/null
+++ b/.werks/4200
@@ -0,0 +1,11 @@
+Title: Fix computation of Event Console performance snapin in distributed mode
+Level: 2
+Component: ec
+Compatible: compat
+Version: 1.4.0i4
+Date: 1482244286
+Class: fix
+
+This contents of the sidebar snapin {{Event Console Performance}} showed invalid
+data in case of a multi-sited distributed Event Console: It only show data from
+one random instance. This has been fixed.
diff --git a/ChangeLog b/ChangeLog
index 9b465a8..666ffc9 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -34,6 +34,7 @@
* 4155 FIX: Do not perform actions on events if overflow limit is active...
* 4156 FIX: Fix off-by-one error in EC limit handling...
* 4199 FIX: Fix detection of replication mode if EC is distributed...
+ * 4200 FIX: Fix computation of Event Console performance snapin in distributed
mode...
1.4.0i3:
diff --git a/web/htdocs/mkeventd.py b/web/htdocs/mkeventd.py
index d74e5c7..e1cdebe 100644
--- a/web/htdocs/mkeventd.py
+++ b/web/htdocs/mkeventd.py
@@ -237,17 +237,63 @@ def execute_command(name, args=None, site=None):
sites.live().command(query, site)
-def get_status():
- response = sites.live().query("GET eventconsolestatus")
- return dict(zip(response[0], response[1]))
-def replication_mode():
- try:
- status = get_status()
- return status["status_replication_slavemode"]
- except:
- return None
+def get_total_stats():
+ stats_keys = [
+ "status_average_message_rate",
+ "status_average_rule_trie_rate",
+ "status_average_rule_hit_rate",
+ "status_average_event_rate",
+ "status_average_connect_rate",
+ "status_average_overflow_rate",
+ "status_average_rule_trie_rate",
+ "status_average_rule_hit_rate",
+ "status_average_processing_time",
+ "status_average_request_time",
+ "status_average_sync_time",
+ ]
+
+ stats_per_site = list(get_stats_per_site(stats_keys))
+
+ # First simply add rates. Times must then be averaged
+ # weighted by message rate or connect rate
+ total_stats = {}
+ for row in stats_per_site:
+ for key, value in row.items():
+ if key.endswith("rate"):
+ total_stats.setdefault(key, 0.0)
+ total_stats[key] += value
+ if not total_stats:
+ return None # No site answered
+
+ for row in stats_per_site:
+ for time_key, in_relation_to in [
+ ( "status_average_processing_time",
"status_average_message_rate" ),
+ ( "status_average_request_time",
"status_average_connect_rate" ),
+ ]:
+ total_stats.setdefault(time_key, 0.0)
+ if total_stats[in_relation_to]: # avoid division by zero
+ my_weight = row[in_relation_to] / total_stats[in_relation_to]
+ total_stats[time_key] += my_weight * row[time_key]
+
+ total_sync_time = 0.0
+ count = 0
+ for row in stats_per_site:
+ if row["status_average_sync_time"] > 0.0:
+ count += 1
+ total_sync_time += row["status_average_sync_time"]
+
+ if count > 0:
+ total_stats["status_average_sync_time"] = total_sync_time / count
+
+ return total_stats
+
+
+def get_stats_per_site(stats_keys):
+ for list_row in sites.live().query("GET eventconsolestatus\nColumns: %s" %
" ".join(stats_keys)):
+ yield dict(zip(stats_keys, list_row))
+
# Rule matching for simulation. Yes - there is some hateful code duplication
diff --git a/web/plugins/sidebar/mkeventd.py b/web/plugins/sidebar/mkeventd.py
index c992bf7..655f5c7 100644
--- a/web/plugins/sidebar/mkeventd.py
+++ b/web/plugins/sidebar/mkeventd.py
@@ -33,7 +33,7 @@ except:
def mkeventd_performance_entries():
- status = mkeventd.get_status()
+ status = mkeventd.get_total_stats() # combination of several sites
entries = []
# TODO: Reorder these values and create a useful order.
@@ -84,8 +84,15 @@ def mkeventd_performance_entries():
def render_mkeventd_performance():
+ try:
+ entries = mkeventd_performance_entries()
+ except Exception, e:
+ raise
+ html.show_error(e)
+ return
+
html.open_table(class_=["mkeventd_performance"])
- for index, left, right in mkeventd_performance_entries():
+ for index, left, right in entries:
html.tr(
html.render_td("%s:" % left) +
html.render_td(right))