Module: check_mk
Branch: master
Commit: 4cb110e49102515f1519953242bde7d73ec3a95a
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=4cb110e4910251…
Author: Andreas Boesl <ab(a)mathias-kettner.de>
Date: Wed Jun 26 10:05:15 2013 +0200
rule editor: fixed, now with check item determination
---
modules/automation.py | 1 +
web/htdocs/wato.py | 16 +++++++++++-----
2 files changed, 12 insertions(+), 5 deletions(-)
diff --git a/modules/automation.py b/modules/automation.py
index f7eb9fa..c73f949 100644
--- a/modules/automation.py
+++ b/modules/automation.py
@@ -591,6 +591,7 @@ def automation_get_check_information():
checks[check_type] = { "title" : title }
if check["group"]:
checks[check_type]["group"] = check["group"]
+ checks[check_type]["service_description"] =
check.get("service_description","%s")
checks[check_type]["snmp"] = check_uses_snmp(check_type)
return checks
diff --git a/web/htdocs/wato.py b/web/htdocs/wato.py
index 5a045b1..51f6cb8 100644
--- a/web/htdocs/wato.py
+++ b/web/htdocs/wato.py
@@ -10083,23 +10083,29 @@ def create_new_rule_form(rulespec, hostname = None, item = None,
varname = None)
def mode_edit_ruleset(phase):
varname = html.var("varname")
-
+
+ item = None
if html.var("check_command"):
check_command = html.var("check_command")
checks = check_mk_local_automation("get-check-information")
if check_command.startswith("check_mk-"):
check_command = check_command[9:]
varname = "checkgroup_parameters:" +
checks[check_command].get("group","")
+ descr_pattern =
checks[check_command]["service_description"].replace("%s",
"(.*)")
+ matcher = re.search(descr_pattern,
html.var("service_description"))
+ if matcher:
+ item = matcher.group(1)
elif check_command.startswith("check_mk_active-"):
check_command = check_command[16:].split(" ")[0][:-1]
varname = "active_checks:" + check_command
rulespec = g_rulespecs.get(varname)
hostname = html.var("host", "")
- if html.has_var("item"):
- item = mk_eval(html.var("item"))
- else:
- item = NO_ITEM
+ if not item:
+ if html.has_var("item"):
+ item = mk_eval(html.var("item"))
+ else:
+ item = NO_ITEM
if hostname:
hosts = load_hosts(g_folder)