Module: check_mk
Branch: master
Commit: d1e426bb9ee5d69bc08b9424f8f2b785a7a3e40d
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=d1e426bb9ee5d6…
Author: Mathias Kettner <mk(a)mathias-kettner.de>
Date: Sat Nov 27 13:57:14 2010 +0100
wato: buttons for adding/removing all services
---
web/htdocs/htmllib.py | 3 +++
web/htdocs/wato.py | 44 +++++++++++++++++++++++++++++++++-----------
2 files changed, 36 insertions(+), 11 deletions(-)
diff --git a/web/htdocs/htmllib.py b/web/htdocs/htmllib.py
index ddae25f..3fb7a74 100644
--- a/web/htdocs/htmllib.py
+++ b/web/htdocs/htmllib.py
@@ -433,6 +433,9 @@ class html:
def set_var(self, varname, value):
self.req.vars[varname] = value
+ def del_var(self, varname):
+ del self.req.vars[varname]
+
def javascript(self, code):
self.write("<script
language=\"javascript\">\n%s\n</script>\n" % code)
diff --git a/web/htdocs/wato.py b/web/htdocs/wato.py
index 3f55574..00399fe 100644
--- a/web/htdocs/wato.py
+++ b/web/htdocs/wato.py
@@ -412,15 +412,21 @@ def mode_inventory(phase, firsttime):
table = check_mk_automation("try-inventory", ["tcp",
hostname])
table.sort()
active_checks = {}
+ new_target = "index"
for st, ct, item, paramstring, params, descr, state, output, perfdata in
table:
- varname = "_%s_%s" % (ct, item)
- if html.var(varname, "") != "":
+ if (html.has_var("_cleanup") or
html.has_var("_fixall")) and st in [ "vanished", "obsolete"
]:
+ pass
+ elif (html.has_var("_activate_all") or
html.has_var("_fixall")) and st == "new":
active_checks[(ct, item)] = paramstring
+ else:
+ varname = "_%s_%s" % (ct, item)
+ if html.var(varname, "") != "":
+ active_checks[(ct, item)] = paramstring
check_mk_automation("set-autochecks", [hostname], active_checks)
message = "Saved check configuration of host [%s] with %d checks" %
(hostname, len(active_checks))
log_pending(hostname, "set-autochecks", message)
- return "index", message
+ return new_target, message
return "index"
elif phase == "buttons":
@@ -600,17 +606,33 @@ def show_service_table(hostname, firsttime):
table.sort()
html.begin_form("checks")
- html.button("_save", "Save check configuration")
+ fixall = 0
+ for entry in table:
+ if entry[0] == 'new' and not html.has_var("_activate_all") and
not firsttime:
+ html.button("_activate_all", "Activate missing")
+ fixall += 1
+ break
+ for entry in table:
+ if entry[0] in [ 'obsolete', 'vanished', ]:
+ html.button("_cleanup", "Remove exceeding")
+ fixall += 1
+ break
+ if fixall == 2:
+ html.button("_fixall", "Fix all missing/exceeding")
+
+
+ html.button("_save", "Save manual check configuration")
html.hidden_fields()
html.write("<table class=services>\n")
+
for state_name, state_type, checkbox in [
- ( "Available checks", "new", firsttime ),
- ( "Already configured checks", "old", True, ),
- ( "Obsolete checks (being checked, but should be ignored)",
"obsolete", True ),
- ( "Ignored checks (configured away by admin)", "ignored",
False ),
- ( "Vanished checks (checks, but no longer exist)",
"vanished", True ),
- ( "Manual checks (defined in main.mk)", "manual", None ),
- ( "Legacy checks (defined in main.mk)", "legacy", None )
+ ( "Available (missing) services", "new", firsttime ),
+ ( "Already configured services", "old", True, ),
+ ( "Obsolete services (being checked, but should be ignored)",
"obsolete", True ),
+ ( "Ignored services (configured away by admin)", "ignored",
False ),
+ ( "Vanished services (checked, but no longer exist)",
"vanished", True ),
+ ( "Manual services (defined in main.mk)", "manual", None ),
+ ( "Legacy services (defined in main.mk)", "legacy", None )
]:
first = True
trclass = "even"