Module: check_mk
Branch: master
Commit: e6c81447bf842d0341d4e898247cc657d0e6ec5e
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=e6c81447bf842d…
Author: Mathias Kettner <mk(a)mathias-kettner.de>
Date: Thu Mar 29 16:32:34 2012 +0200
BI: Avoid duplicate rule incarnations when using FOREACH_*
---
ChangeLog | 1 +
web/htdocs/bi.py | 10 ++++++++--
2 files changed, 9 insertions(+), 2 deletions(-)
diff --git a/ChangeLog b/ChangeLog
index e8dcab1..3d5262a 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -12,6 +12,7 @@
* FIX: Fixed filtering of Single-Host Aggregations
* New sorter for aggregation group
* FIX: fix sorting of Single-Host Aggregations after group
+ * Avoid duplicate rule incarnations when using FOREACH_*
Checks & Agents:
* FIX: snmp_uptime handles empty snmp information without exception
diff --git a/web/htdocs/bi.py b/web/htdocs/bi.py
index 2241acf..943d3be 100644
--- a/web/htdocs/bi.py
+++ b/web/htdocs/bi.py
@@ -245,9 +245,12 @@ def compile_rule_node(calllist, lvl):
if calllist[0] in [ config.FOREACH_HOST, config.FOREACH_SERVICE ]:
matches = find_matching_services(calllist[0], calllist[1:])
new_elements = []
+ handled_args = set([]) # avoid duplicate rule incarnations
for match in matches:
args = [ substitute_matches(a, match) for a in arglist ]
- new_elements += compile_aggregation_rule(rule, args, lvl)
+ if tuple(args) not in handled_args:
+ new_elements += compile_aggregation_rule(rule, args, lvl)
+ handled_args.add(tuple(args))
return new_elements
else:
@@ -474,9 +477,12 @@ def compile_aggregation_rule(rule, args, lvl = 0):
# 2: (['waage'], '(.*)')
matches = find_matching_services(config.FOREACH_HOST, node[1:-2])
new_elements = []
+ handled_args = set([]) # avoid duplicate rule incarnations
for match in matches:
arginfo = {'HOST': match[0]}
- new_elements += compile_leaf_node(subst_vars(node[-2], arginfo),
subst_vars(node[-1], arginfo))
+ if tuple(args) not in handled_args:
+ new_elements += compile_leaf_node(subst_vars(node[-2], arginfo),
subst_vars(node[-1], arginfo))
+ handled_args.add(tuple(args))
host_name, service_description = node[-2:]
else: