From: Peter Palfrader Date: Thu, 3 Apr 2008 12:26:44 +0000 (-0400) Subject: [project @ peter@palfrader.org-20080403122644-2anbhbkduhrw967g] X-Git-Url: https://git.adam-barratt.org.uk/?a=commitdiff_plain;ds=sidebyside;h=a46df3797d1eb579701f86cb294261ef61212541;p=mirror%2Fdsa-nagios.git [project @ peter@palfrader.org-20080403122644-2anbhbkduhrw967g] Instead of using the extinfo of the first hostgroup, is the extinfo of the first hostgroup that actually has extinfo --- diff --git a/build-nagios b/build-nagios index 67f7e15..3e3e09e 100755 --- a/build-nagios +++ b/build-nagios @@ -292,12 +292,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')