Module: check_mk
Branch: master
Commit: 3163b096f08117921423571ee814875491ad7cf6
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=3163b096f08117…
Author: Mathias Kettner <mk(a)mathias-kettner.de>
Date: Fri Oct 11 20:54:04 2013 +0200
Create inventory check also for hosts without services
---
ChangeLog | 4 ++++
modules/check_mk.py | 49 +++++++++++++++++++++++++++----------------------
2 files changed, 31 insertions(+), 22 deletions(-)
diff --git a/ChangeLog b/ChangeLog
index 1802f05..694b7fd 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,4 +1,8 @@
1.2.3i4:
+ Core:
+ * Create inventory check also for hosts without services, if they
+ have *no* ping tag.
+
WATO:
* Bulk inventory: speed up by use of cache files and doing stuff in
groups of e.g. 10 hosts at once
diff --git a/modules/check_mk.py b/modules/check_mk.py
index 34a57a0..f30f7a2 100755
--- a/modules/check_mk.py
+++ b/modules/check_mk.py
@@ -2043,28 +2043,6 @@ define service {
%s service_description\t\tCheck_MK
}
""" % (active_service_template, hostname, extra_service_conf_of(hostname,
"Check_MK")))
- # Inventory checks - if user has configured them. Not for clusters.
- if inventory_check_interval and not is_cluster(hostname) \
- and not service_ignored(hostname,None,'Check_MK inventory'):
- outfile.write("""
-define service {
- use\t\t\t\t%s
- host_name\t\t\t%s
- normal_check_interval\t\t%d
- retry_check_interval\t\t%d
-%s service_description\t\tCheck_MK inventory
-}
-
-define servicedependency {
- use\t\t\t\t%s
- host_name\t\t\t%s
- service_description\t\tCheck_MK
- dependent_host_name\t\t%s
- dependent_service_description\tCheck_MK inventory
-}
-""" % (inventory_check_template, hostname, inventory_check_interval,
inventory_check_interval,
- extra_service_conf_of(hostname, "Check_MK inventory"),
- service_dependency_template, hostname, hostname))
# legacy checks via legacy_checks
legchecks = host_extra_conf(hostname, legacy_checks)
@@ -2218,6 +2196,33 @@ define service {
# write service dependencies for custom checks
outfile.write(get_dependencies(hostname,description))
+ # Inventory checks - if user has configured them. Not for clusters.
+ if inventory_check_interval and not is_cluster(hostname) \
+ and not service_ignored(hostname, None, 'Check_MK inventory') \
+ and not "ping" in tags_of_host(hostname):
+ outfile.write("""
+define service {
+ use\t\t\t\t%s
+ host_name\t\t\t%s
+ normal_check_interval\t\t%d
+ retry_check_interval\t\t%d
+%s service_description\t\tCheck_MK inventory
+}
+""" % (inventory_check_template, hostname, inventory_check_interval,
+ inventory_check_interval,
+ extra_service_conf_of(hostname, "Check_MK inventory")))
+
+ if have_at_least_one_service:
+ outfile.write("""
+define servicedependency {
+ use\t\t\t\t%s
+ host_name\t\t\t%s
+ service_description\t\tCheck_MK
+ dependent_host_name\t\t%s
+ dependent_service_description\tCheck_MK inventory
+}
+""" % (service_dependency_template, hostname, hostname))
+
# Levels for host check
if is_cluster(hostname):
ping_command = 'check-mk-ping-cluster'