Module: check_mk
Branch: master
Commit: 42a0c4c0502784d081f0f4771e35311591dee620
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=42a0c4c0502784…
Author: Götz Golla <gg(a)mathias-kettner.de>
Date: Mon Aug 26 17:03:19 2013 +0200
service dependencies for legacy, active and custom checks implemented
---
modules/check_mk.py | 25 ++++++++++++++++++++++++-
1 file changed, 24 insertions(+), 1 deletion(-)
diff --git a/modules/check_mk.py b/modules/check_mk.py
index 5638b8f..8e9efd3 100755
--- a/modules/check_mk.py
+++ b/modules/check_mk.py
@@ -1801,6 +1801,21 @@ def create_nagios_servicedefs(outfile, hostname):
return True
return False
+ def get_dependencies(hostname,servicedesc):
+ result = ""
+ for dep in service_deps(hostname, servicedesc):
+ result += """
+define servicedependency {
+ use\t\t\t\t%s
+ host_name\t\t\t%s
+ service_description\t%s
+ dependent_host_name\t%s
+ dependent_service_description %s
+}\n
+""" % (service_dependency_template, hostname, dep, hostname, servicedesc)
+
+ return result
+
host_checks = get_check_table(hostname).items()
host_checks.sort() # Create deterministic order
aggregated_services_conf = set([])
@@ -1942,7 +1957,7 @@ define service {
define service {
use\t\t\t\t%s
host_name\t\t\t%s
- normal_check_interval\t\t%d
+ normal_check_interval\t\t%d
retry_check_interval\t\t%d
%s service_description\t\tCheck_MK inventory
}
@@ -1992,6 +2007,9 @@ define service {
%s}
""" % (template, hostname, make_utf8(description),
simulate_command(command), extraconf))
+ # write service dependencies for legacy checks
+ outfile.write(get_dependencies(hostname,description))
+
# legacy checks via active_checks
actchecks = []
needed_commands = []
@@ -2043,6 +2061,8 @@ define service {
%s}
""" % (template, hostname, make_utf8(description),
simulate_command(command), extraconf))
+ # write service dependencies for active checks
+ outfile.write(get_dependencies(hostname,description))
# Legacy checks via custom_checks
custchecks = host_extra_conf(hostname, custom_checks)
@@ -2111,6 +2131,9 @@ define service {
""" % (template, hostname, make_utf8(description),
simulate_command(command),
(command_line and not freshness) and 1 or 0, extraconf, freshness))
+ # write service dependencies for custom checks
+ outfile.write(get_dependencies(hostname,description))
+
# Levels for host check
if is_cluster(hostname):
ping_command = 'check-mk-ping-cluster'