X-Git-Url: https://git.adam-barratt.org.uk/?a=blobdiff_plain;f=config%2Fbuild-nagios;h=50a182a2fa310b220bcf41e94c729e0bc743c732;hb=27304ea558a7ad65486ff4b0a07c2a1407b7d88d;hp=13c3d4ce59a3fee980e070dea3d83d24fa4c720c;hpb=d821b6d6f3442fa6a428d31020d920c58f931cca;p=mirror%2Fdsa-nagios.git diff --git a/config/build-nagios b/config/build-nagios index 13c3d4c..50a182a 100755 --- a/config/build-nagios +++ b/config/build-nagios @@ -46,6 +46,7 @@ HOST_TEMPLATE_NAME='generic-host' # host templates that all our host de SERVICE_TEMPLATE_NAME='generic-service' # host templates that all our host definitions use HOST_ALIVE_CHECK='check-host-alive' # host alive check if server is pingable NRPE_PROCESS_SERVICE='process - nrpe' # nrpe checks will depend on this one +NRPE_LOAD_CHECK='load' def warn (msg) @@ -127,11 +128,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}" } @@ -166,7 +169,12 @@ def addService(hosts, service, files, servers) service['check_command'] = "#{ NRPE_CHECKNAME }!#{ check }" service['depends'] = ensure_array( service['depends'] ) - service['depends'] << NRPE_PROCESS_SERVICE unless service['service_description'] == NRPE_PROCESS_SERVICE # Depend on NRPE unless we are it + unless service['service_description'] == NRPE_PROCESS_SERVICE + # Depend on the load check to reduce noise + service['depends'] << NRPE_LOAD_CHECK unless service['service_description'] == NRPE_LOAD_CHECK + # Depend on NRPE unless we are it + service['depends'] << NRPE_PROCESS_SERVICE + end end hosts.each{ |host| @@ -239,9 +247,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 }