Module: check_mk
Branch: master
Commit: 12af605c008467cb4dc154284b5680cc3ad7f720
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=12af605c008467…
Author: Andreas Boesl <ab(a)mathias-kettner.de>
Date: Thu Jun 13 16:04:48 2013 +0200
set ignored/clustered services without reinventorize
---
ChangeLog | 3 +++
modules/automation.py | 42 +++++++++++++++++++++++++++++-------------
modules/check_mk.py | 26 +++++++++++++++++++++++---
3 files changed, 55 insertions(+), 16 deletions(-)
diff --git a/ChangeLog b/ChangeLog
index 61a1d66..73ab12a 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -15,6 +15,9 @@
Checks & Agents:
* esx_hostystem multipath: criticize standby paths only if not equal to active paths
* mk_logwatch: fixed bug when rewriting logwatch messages
+ * check_mk: Re-inventory is no longer required when a service is ignored via rule
+ * check_mk: Now possible to assign services to clusters without the need to
+ reinventorize
WATO:
* Allow to configure check-/retry_interval in second precision
diff --git a/modules/automation.py b/modules/automation.py
index 344070c..7f390f8 100644
--- a/modules/automation.py
+++ b/modules/automation.py
@@ -348,23 +348,39 @@ def automation_try_inventory_node(hostname):
def automation_set_autochecks(args):
hostname = args[0]
new_items = eval(sys.stdin.read())
-
do_cleanup_autochecks()
- existing = automation_parse_autochecks_file(hostname)
- # write new autochecks file, but take paramstrings from existing ones
- # for those checks which are kept
- new_autochecks = []
- for ct, item, params, paramstring in existing:
- if (ct, item) in new_items:
+ # A Cluster does not have an autochecks file
+ # All of its services are located in the nodes instead
+ # So we cycle through all nodes remove all clustered service
+ # and add the ones we've got from stdin
+ if is_cluster(hostname):
+ for node in nodes_of(hostname):
+ new_autochecks = []
+ existing = automation_parse_autochecks_file(node)
+ for ct, item, params, paramstring in existing:
+ descr = service_description(ct, item)
+ if node == host_of_clustered_service(node, descr):
+ new_autochecks.append((ct, item, paramstring))
+ for (ct, item), paramstring in new_items.items():
+ new_autochecks.append((ct, item, paramstring))
+ # write new autochecks file for that host
+ automation_write_autochecks_file(node, new_autochecks)
+ else:
+ existing = automation_parse_autochecks_file(hostname)
+ # write new autochecks file, but take paramstrings from existing ones
+ # for those checks which are kept
+ new_autochecks = []
+ for ct, item, params, paramstring in existing:
+ if (ct, item) in new_items:
+ new_autochecks.append((ct, item, paramstring))
+ del new_items[(ct, item)]
+
+ for (ct, item), paramstring in new_items.items():
new_autochecks.append((ct, item, paramstring))
- del new_items[(ct, item)]
-
- for (ct, item), paramstring in new_items.items():
- new_autochecks.append((ct, item, paramstring))
- # write new autochecks file for that host
- automation_write_autochecks_file(hostname, new_autochecks)
+ # write new autochecks file for that host
+ automation_write_autochecks_file(hostname, new_autochecks)
def automation_get_autochecks(args):
diff --git a/modules/check_mk.py b/modules/check_mk.py
index adfe554..1d034c3 100755
--- a/modules/check_mk.py
+++ b/modules/check_mk.py
@@ -945,6 +945,10 @@ def get_check_table(hostname):
if hosttags_match_taglist(tags_of_host(hostname), tags) and \
in_extraconf_hostlist(hostlist, hostname):
descr = service_description(checkname, item)
+ if service_ignored(hostname, checkname, descr):
+ return
+ if hostname != host_of_clustered_service(hostname, descr):
+ return
deps = service_deps(hostname, descr)
check_table[(checkname, item)] = (params, descr, deps)
@@ -956,6 +960,22 @@ def get_check_table(hostname):
for entry in g_multihost_checks:
handle_entry(entry)
+ # Now add checks a cluster might receive from its nodes
+ if is_cluster(hostname):
+ for node in nodes_of(hostname):
+ node_checks = g_singlehost_checks.get(node) or []
+ for entry in node_checks:
+ if len(entry) == 4:
+ hostlist, checkname, item, params = entry
+ tags = []
+ elif len(entry) == 5:
+ tags, hostlist, checkname, item, params = entry
+ descr = service_description(checkname, item)
+ # TODO: single / multihost - crasht auf jeden fall
+ if hostname == host_of_clustered_service(node, descr):
+ handle_entry(((hostname,) + entry[1:]))
+
+
# Remove dependencies to non-existing services
all_descr = set([ descr for ((checkname, item), (params, descr, deps)) in
check_table.items() ])
for (checkname, item), (params, descr, deps) in check_table.items():
@@ -2488,14 +2508,14 @@ def make_inventory(checkname, hostnamelist, check_only=False,
include_state=Fals
else:
continue # user does not want this item to be checked
- newcheck = ' ("%s", "%s", %r, %s),' % (hn,
checkname, item, paramstring)
+ newcheck = ' ("%s", "%s", %r, %s),' %
(hostname, checkname, item, paramstring)
newcheck += "\n"
if newcheck not in newchecks: # avoid duplicates if inventory outputs
item twice
newchecks.append(newcheck)
if include_state:
- newitems.append( (hn, checkname, item, paramstring, state_type)
)
+ newitems.append( (hostname, checkname, item, paramstring,
state_type) )
else:
- newitems.append( (hn, checkname, item) )
+ newitems.append( (hostname, checkname, item) )
count_new += 1