summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPeter Palfrader <peter@palfrader.org>2009-03-26 13:55:21 +0000
committerweasel <weasel@bc3d92e2-beff-0310-a7cd-cc87d7ac0ede>2009-03-26 13:55:21 +0000
commitf88d5d44d7b9493dee9da570fefe1babc5983871 (patch)
tree1ea89293a61c7fb804bf860a932c066d055a6e9c
parent4f79e6ddffa8c988c4f651546131bcb5985b9721 (diff)
Merge host contacts with service contacts
git-svn-id: svn+ssh://asteria.noreply.org/svn/weaselutils/trunk@382 bc3d92e2-beff-0310-a7cd-cc87d7ac0ede
-rwxr-xr-xbuild-nagios13
1 files changed, 10 insertions, 3 deletions
diff --git a/build-nagios b/build-nagios
index 415eabd..2ace17c 100755
--- a/build-nagios
+++ b/build-nagios
@@ -136,6 +136,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
@@ -160,9 +169,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