popov runs heavy-exim
[mirror/dsa-nagios.git] / config / build-nagios
index 94a2b53..1eb3977 100755 (executable)
@@ -127,11 +127,13 @@ $nrpe = Nrpe.new()
 # host/service/etc definitions
 #
 # It skips over such keys as are listed in exclude_keys
-# and also skips private keys (those starting with an underscre)
+# and also skips private keys (those starting with an underscore)
 def print_block(fd, kind, hash, exclude_keys)
        fd.puts "define #{kind} {"
        hash.each_pair{ |key, value|
-               next if key[0,1] == '_'
+               next if key == '_extinfo'
+               next if key == '_hostgroups'
+               next if key == '_memberlist'
                next if exclude_keys.include? key
                fd.puts "       #{key}          #{value}"
        }
@@ -239,9 +241,9 @@ def find_hosts(service, servers, hostgroups)
        hosts        = merge_hosts_and_hostgroups service, servers, hostgroups, ''
        excludehosts = merge_hosts_and_hostgroups service, servers, hostgroups, 'exclude'
 
-       excludehosts.each{ |host|
+       excludehosts.uniq.each{ |host|
                if hosts.delete(host) == nil
-                       throw "Cannot remove host #{host} from service #{service['service_description']}: it's not included anyway or excluded twice."
+                       puts "info: [service #{service['service_description']}] not excluding host #{host} - it's not included anyway."
                end
        }
 
@@ -358,6 +360,7 @@ config['servers'].each_pair{ |name, server|
 ##############
 config['hostgroups'].each_pair{ |name, hg|
        next if hg['private']
+       throw "Empty hostgroup #{name}" if hg['_memberlist'].length == 0
 
        set_complain_if_set hg, 'hostgroup_name', name                       , 'Hostgroup', name
        set_complain_if_set hg, 'members'       , hg['_memberlist'].join(","), 'Hostgroup', name