From: Peter Palfrader Date: Tue, 27 Jan 2009 16:31:42 +0000 (+0000) Subject: [project @ peter@palfrader.org-20090127163142-t5ubqccc19k7s20l] X-Git-Url: https://git.adam-barratt.org.uk/?a=commitdiff_plain;h=9ade31a73bd87b1304c60d993f7ce13cd7b35ea3;p=mirror%2Fdsa-nagios.git [project @ peter@palfrader.org-20090127163142-t5ubqccc19k7s20l] Allow merging of contact definition from services and hosts. in fact it is no longer possible to override host contacts per service but that could be added back if we ever need it --- diff --git a/build-nagios b/build-nagios index e7bc540..8475da8 100755 --- a/build-nagios +++ b/build-nagios @@ -117,6 +117,15 @@ def print_block(fd, kind, hash, exclude_keys) fd.puts end +def merge_contacts(host, service) + %w{contacts contact_groups}.each{ |k| + contacts = [] + [host, service].each{ |source| + contacts.push source[k] if source.has_key?(k) + } + service[k] = contacts.join(",") unless contacts.empty? + } +end # Add the service definition service to hosts # f is the file for service definitions, deps the file for dependencies @@ -141,9 +150,7 @@ def addService(hosts, service, files, servers) hosts.each{ |host| s = service.clone set_complain_if_set s, 'host_name', host, 'Service', s['service_description'] - %w{contacts contact_groups}.each{ |k| - set_if_unset(s, k, servers[host][k]) if servers[host].has_key? k - } + merge_contacts(servers[host], s) print_block files['services'], 'service', s, %w(nrpe runfrom remotecheck depends