Module: check_mk
Branch: master
Commit: 68fb857c85fdbe9b10c621a6f3ca08762316bf55
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=68fb857c85fdbe…
Author: Mathias Kettner <mk(a)mathias-kettner.de>
Date: Sun Nov 14 08:54:11 2010 +0100
webconf: display service table correctly
---
modules/check_mk.py | 4 ++--
web/htdocs/htmllib.py | 2 +-
web/htdocs/webconf.py | 46 ++++++++++++++++++++++++++++++++--------------
3 files changed, 35 insertions(+), 17 deletions(-)
diff --git a/modules/check_mk.py b/modules/check_mk.py
index 17e47cf..c7b0fc0 100755
--- a/modules/check_mk.py
+++ b/modules/check_mk.py
@@ -3455,7 +3455,7 @@ def automation_try_inventory(args):
try:
result = check_function(item, params, info)
except MKCounterWrapped, e:
- result = (0, "WAITING - Counter based check, cannot be done
offline")
+ result = (None, "WAITING - Counter based check, cannot be done
offline")
except Exception, e:
result = (3, "UNKNOWN - invalid output from agent or error in check
implementation")
if len(result) == 2:
@@ -3463,7 +3463,7 @@ def automation_try_inventory(args):
exitcode, output, perfdata = result
else:
descr = item
- exitcode = 0
+ exitcode = None
output = "WAITING - Legacy check, cannot be done offline"
perfdata = []
table.append((state_type, ct, item, params, descr, exitcode, output, perfdata))
diff --git a/web/htdocs/htmllib.py b/web/htdocs/htmllib.py
index 88143a7..dbd31e2 100644
--- a/web/htdocs/htmllib.py
+++ b/web/htdocs/htmllib.py
@@ -275,7 +275,7 @@ class html:
checked = " CHECKED"
else:
checked = ""
- self.write("<input type=checkbox name=%s%s>" % (varname,
checked))
+ self.write("<input type=checkbox name=\"%s\"%s>" %
(urlencode(varname), checked))
self.form_vars.append(varname)
def datetime_input(self, varname, default_value):
diff --git a/web/htdocs/webconf.py b/web/htdocs/webconf.py
index 8ce32b9..14db080 100644
--- a/web/htdocs/webconf.py
+++ b/web/htdocs/webconf.py
@@ -272,29 +272,47 @@ def page_services(h):
raise MKGeneralException("Error calling check_mk: %s, exit code %s" %
(code, exit_code))
table = eval(code)
table.sort()
-
+
+
+ html.begin_form("checks")
+ html.button("add", "Add marked checks")
+ html.button("remove", "Remove marked checks")
+ html.hidden_fields()
html.write("<table class=services>\n")
- for state_name, state_type in [
- ( "Existing checks", "old", ),
- ( "Available checks", "new", ),
- ( "Ignored checks (configured away by admin)", "ignored" ),
- ( "Obsolete checks (being checked, but should be ignored)",
"obsolete" ),
- ( "Vanished checks (checks, but no longer exist)", "vanished"
),
- ( "Manual checks (defined in main.mk)", "manual" ),
- ( "Legacy checks (defined in main.mk)", "legacy")
+ for state_name, state_type, checkbox in [
+ ( "Available checks", "new", True ),
+ ( "Ignored checks (configured away by admin)", "ignored",
False ),
+ ( "Already configured checks", "old", False, ),
+ ( "Obsolete checks (being checked, but should be ignored)",
"obsolete", False ),
+ ( "Vanished checks (checks, but no longer exist)",
"vanished", False ),
+ ( "Manual checks (defined in main.mk)", "manual", None ),
+ ( "Legacy checks (defined in main.mk)", "legacy", None)
]:
first = True
+ trclass = "even"
for st, ct, item, params, descr, state, output, perfdata in table:
if state_type != st:
continue
if first:
- html.write("<tr><td
colspan=7>%s</td></tr>\n" % state_name)
-
html.write("<tr><th>Checktype</th><th>Item</th><th>Service
Description</th><th>Status</th><th>Current
check</th></tr>\n")
+ html.write('<tr class=groupheader><td
colspan=7><br>%s</td></tr>\n' % state_name)
+
html.write("<tr><th>Status</th><th>Checktype</th><th>Item</th>"
+ "<th>Service
Description</th><th>Current
check</th><th></th></tr>\n")
first = False
-
html.write("<tr><td>%s</td><td>%s</td><td>%s</td><td>%s</td><td>%s</td>"
%
- (ct, item, descr, state, output))
+ trclass = trclass == "even" and "odd" or
"even"
+ statename = nagios_short_state_names.get(state, "PEND")
+ if statename == "PEND":
+ stateclass = "state svcstate statep"
+ state = 0 # for tr class
+ else:
+ stateclass = "state svcstate state%s" % state
+ html.write("<tr class=\"data %s%d\"><td
class=\"%s\">%s</td><td>%s</td><td>%s</td><td>%s</td><td>%s</td><td>"
%
+ (trclass, state, stateclass, statename, ct, item, descr, output))
+ if checkbox != None:
+ varname = "%s %s" % (ct, item)
+ html.checkbox(varname, checkbox)
+ html.write("</td></tr>\n")
html.write("</table>\n")
-
+ html.end_form()
html.footer()