require "yaml"
ORG="dsa"
-SHORTORG="do"
-CONTACTGROUP="debianadmin"
+SHORTORG="dsa"
GENERATED_PREFIX="./generated/"
nagios_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)
# 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')