X-Git-Url: https://git.adam-barratt.org.uk/?a=blobdiff_plain;f=build-nagios;h=482357fdcd5c0edc9babb00597c019aca1073b5e;hb=5224b1ec9299c9304984ff299c4dfd81860f4551;hp=a6148714d9fa7607f5e03fd5d7d29ad90854b818;hpb=e3a4b38b12c107058df78ff0b2c55543cd4a3820;p=mirror%2Fdsa-nagios.git diff --git a/build-nagios b/build-nagios index a614871..482357f 100755 --- a/build-nagios +++ b/build-nagios @@ -1,13 +1,12 @@ #!/usr/bin/ruby -# Copyright (c) 2004, 2005, 2006, 2007 Peter Palfrader +# Copyright (c) 2004, 2005, 2006, 2007, 2008 Peter Palfrader require "yaml" -ORG="relativity" -SHORTORG="rela" -CONTACTGROUP="weaselgroup" -GENERATED_PREFIX="/etc/NOREPLY/generated/nagios/" +ORG="dsa" +SHORTORG="dsa" +GENERATED_PREFIX="./generated/" nagios_filename = {}; %w(hosts hostgroups services dependencies hostextinfo serviceextinfo).each{ @@ -245,8 +244,10 @@ nagios_filename.each_pair{ |name, filename| # create the "all" and "pingable" hostgroups config['hostgroups']['all'] = {} config['hostgroups']['all']['alias'] = "all servers" +config['hostgroups']['all']['private'] = true config['hostgroups']['pingable'] = {} config['hostgroups']['pingable']['alias'] = "pingable servers" +config['hostgroups']['pingable']['private'] = true config['hostgroups'].each_pair{ |name, hg| throw "Empty hostgroup or hostgroup #{name} not a hash" unless hg.kind_of?(Hash) @@ -293,12 +294,17 @@ config['servers'].each_pair{ |name, server| # Handle hostextinfo - config['hostgroups'][ server['_hostgroups'].first ]['_extinfo'].each_pair{ |k, v| - # substitute hostname into the notes_url - v = sprintf(v,name) if k == 'notes_url' - - set_if_unset server['_extinfo'], k ,v - } + #config['hostgroups'][ server['_hostgroups'].first ]['_extinfo'].each_pair{ |k, v| + # find the first hostgroup that has extinfo + extinfo = server['_hostgroups'].collect{ |hgname | config['hostgroups'][hgname]['_extinfo'] }.delete_if{ |ei| ei.size == 0 }.first + if extinfo then + extinfo.each_pair do |k, v| + # substitute hostname into the notes_url + v = sprintf(v,name) if k == 'notes_url' + + set_if_unset server['_extinfo'], k ,v + end + end set_complain_if_set server['_extinfo'], 'host_name' , name, 'hostextinfo', name set_if_unset server['_extinfo'], 'vrml_image' , server['_extinfo']['icon_image'] if server['_extinfo'].has_key?('icon_image') @@ -317,7 +323,6 @@ config['hostgroups'].each_pair{ |name, hg| set_complain_if_set hg, 'hostgroup_name', name , 'Hostgroup', name set_complain_if_set hg, 'members' , hg['_memberlist'].join(","), 'Hostgroup', name - set_if_unset hg, 'contact_groups', CONTACTGROUP print_block files['hostgroups'], 'hostgroup', hg, %w() }