Module: check_mk
Branch: master
Commit: bf4f960e97a07c67e931292892d5c51991f03052
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=bf4f960e97a07c…
Author: Mathias Kettner <mk(a)mathias-kettner.de>
Date: Wed Oct 9 22:39:32 2013 +0200
Bulk inventory: checkbox for skipping hosts where the agent is critical
---
ChangeLog | 2 ++
web/htdocs/wato.py | 28 ++++++++++++++++++++++------
2 files changed, 24 insertions(+), 6 deletions(-)
diff --git a/ChangeLog b/ChangeLog
index 2221ff0..b172afd 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -43,6 +43,8 @@
* Added title of tests to LDAP diagnose table
* Bulk inventory: new checkbox to only include hosts that have a failed
inventory check.
+ * Bulk inventory: yet another checkbox for skipping hosts where the
+ Check_MK service is currently critical
* FIX: The rule "State and count of processes" is no longer available
in "Parameters for inventorized check". This rule was solely
intented for "Manual checks" configuration
diff --git a/web/htdocs/wato.py b/web/htdocs/wato.py
index 34d6e0e..208afaf 100644
--- a/web/htdocs/wato.py
+++ b/web/htdocs/wato.py
@@ -2657,9 +2657,14 @@ def mode_bulk_inventory(phase):
config.need_permission("wato.services")
if html.get_checkbox("only_failed_invcheck"):
- failed_invcheck_hosts = find_hosts_with_failed_inventory_check()
+ restrict_to_hosts = find_hosts_with_failed_inventory_check()
else:
- failed_invcheck_hosts = None
+ restrict_to_hosts = None
+
+ if html.get_checkbox("only_ok_agent"):
+ skip_hosts = find_hosts_with_failed_agent()
+ else:
+ skip_hosts = []
# 'all' not set -> only inventorize checked hosts
if not html.var("all"):
@@ -2672,7 +2677,8 @@ def mode_bulk_inventory(phase):
hostnames = get_hostnames_from_checkboxes(filterfunc)
items = [ "%s|%s" % (g_folder[".path"], hostname)
for hostname in hostnames
- if (failed_invcheck_hosts == None or hostname in failed_invcheck_hosts) ]
+ if (restrict_to_hosts == None or hostname in restrict_to_hosts) and
+ hostname not in skip_hosts ]
for hostname in hostnames:
check_host_permissions(hostname)
@@ -2683,7 +2689,9 @@ def mode_bulk_inventory(phase):
items = []
hostnames = []
for hostname, folder in entries:
- if failed_invcheck_hosts != None and hostname not in failed_invcheck_hosts:
+ if restrict_to_hosts != None and hostname not in restrict_to_hosts:
+ continue
+ if hostname in skip_hosts:
continue
check_host_permissions(hostname, folder=folder)
items.append("%s|%s" % (folder[".path"], hostname))
@@ -2730,18 +2738,26 @@ def mode_bulk_inventory(phase):
html.checkbox("only_failed", False, label=_("Only include hosts
that failed on previous inventory"))
html.write("<br>")
html.checkbox("only_failed_invcheck", False, label=_("Only include
hosts with a failed inventory check"))
+ html.write("<br>")
+ html.checkbox("only_ok_agent", False, label=_("Exclude hosts where
the agent is unreachable"))
# Start button
forms.end()
html.button("_start", _("Start"))
def find_hosts_with_failed_inventory_check():
- hosts = html.live.query_column(
+ return html.live.query_column(
"GET services\n"
"Filter: description = Check_MK inventory\n"
"Filter: state > 0\n"
"Columns: host_name")
- return hosts
+
+def find_hosts_with_failed_agent():
+ return html.live.query_column(
+ "GET services\n"
+ "Filter: description = Check_MK\n"
+ "Filter: state >= 2\n"
+ "Columns: host_name")
#.
# .-Bulk-Edit------------------------------------------------------------.