Module: check_mk
Branch: master
Commit: 42025d1b22a2a057ec08b9ad0d99e2d0b94b6a0a
URL: http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=42025d1b22a2a0…
Author: Mathias Kettner <mk(a)mathias-kettner.de>
Date: Sat Feb 9 19:01:24 2013 +0100
WATO BI: check for cycles in rules
---
web/htdocs/wato.py | 9 +++++----
1 files changed, 5 insertions(+), 4 deletions(-)
diff --git a/web/htdocs/wato.py b/web/htdocs/wato.py
index 8605019..1098366 100644
--- a/web/htdocs/wato.py
+++ b/web/htdocs/wato.py
@@ -11919,7 +11919,7 @@ def mode_bi_edit_rule(phase):
if phase == "action":
if html.check_transaction():
new_rule = vs_rule.from_html_vars('rule')
- vs_main.validate_value(new_rule, 'rule')
+ vs_rule.validate_value(new_rule, 'rule')
if new:
ruleid = new_rule["id"]
@@ -11932,6 +11932,10 @@ def mode_bi_edit_rule(phase):
log_audit(None, "bi-new-rule", _("Create new BI rule %s") % ruleid)
else:
aggregation_rules[ruleid].update(new_rule)
+ new_rule["id"] = ruleid
+ if bi_rule_uses_rule(aggregation_rules, new_rule, new_rule["id"]):
+ raise MKUserError(None, _("There is a cycle in your rules. This rule calls itself - "
+ "either directly or indirectly."))
log_audit(None, "bi-edit-rule", _("Modified BI rule %s") % ruleid)
save_bi_rules(aggregations, aggregation_rules)
@@ -11954,9 +11958,6 @@ def mode_bi_edit_rule(phase):
html.end_form()
# TODO BI:
-# - Prüfung auf Zyklen in den Regeln. Bzw. die Auswahlbox
-# darf nur Regeln zeigen, die die aktuelle Regel nicht
-# brauchen.
# - Host Tags richtig editieren, nicht mit ListOfStrings.
# Dazu ein ValueSpec machen und dies dann auch im Regel-
# editor verwenden.
Module: check_mk
Branch: master
Commit: f1c8bb0db31ce6cc54f4744562294062eaca5e6e
URL: http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=f1c8bb0db31ce6…
Author: Mathias Kettner <mk(a)mathias-kettner.de>
Date: Mon Feb 4 19:00:43 2013 +0100
Added small helper for creating random services
---
doc/treasures/ds_random | 10 ++++++++++
1 files changed, 10 insertions(+), 0 deletions(-)
diff --git a/doc/treasures/ds_random b/doc/treasures/ds_random
new file mode 100755
index 0000000..40e171e
--- /dev/null
+++ b/doc/treasures/ds_random
@@ -0,0 +1,10 @@
+#!/usr/bin/python
+# Testing script, that can be used as a datasource program
+# and creates a number of random services with random states
+
+import os, random
+
+print '<<<local>>>'
+for service in os.listdir('/'):
+ state = int(random.random() * 4)
+ print "%d Random_%s - Random Random Random" % (state, service)