libraries/default.rb
# decide whether to use internal or external IP addresses for this node
# if the nagios server is not in the cloud, always use public IP addresses for cloud nodes.
# if the nagios server is in the cloud, use private IP addresses for any
#   cloud servers in the same cloud, public IPs for servers in other clouds
#   (where other is defined by node['cloud']['provider'])
# if the cloud IP is nil then use the standard IP address attribute.  This is a work around
#   for OHAI incorrectly identifying systems on Cisco hardware as being in Rackspace
decide whether to use internal or external IP addresses for this node
if the nagios server is not in the cloud, always use public IP addresses for cloud nodes.
if the nagios server is in the cloud, use private IP addresses for any
cloud servers in the same cloud, public IPs for servers in other clouds
(where other is defined by node['cloud']['provider'])
if the cloud IP is nil then use the standard IP address attribute.  This is a work around
for OHAI incorrectly identifying systems on Cisco hardware as being in Rackspace
decide whether to use internal or external IP addresses for this node if the nagios server is not in the cloud always use public IP addresses for cloud nodes . if the nagios server is in the cloud use private IP addresses for any cloud servers in the same cloud public IPs for servers in other clouds ( where other is defined by node [ ' cloud ' ] [ ' provider ' ] ) if the cloud IP is nil then use the standard IP address attribute . This is a work around for OHAI incorrectly identifying systems on Cisco hardware as being in Rackspace
def ip_to_monitor(monitored_host, server_host = node)
  if node['nagios']['monitoring_interface'] && node['network']["ipaddress_#{node['nagios']['monitoring_interface']}"]
    node['network']["ipaddress_#{node['nagios']['monitoring_interface']}"]
  elsif server_host['cloud'].nil? && monitored_host['cloud']
    monitored_host['cloud']['public_ipv4'].include?('.') ? monitored_host['cloud']['public_ipv4'] : monitored_host['ipaddress']
  elsif server_host['cloud'] && monitored_host['cloud'] && monitored_host['cloud']['provider'] != server_host['cloud']['provider']
    monitored_host['cloud']['public_ipv4'].include?('.') ? monitored_host['cloud']['public_ipv4'] : monitored_host['ipaddress']
  else
    monitored_host['ipaddress']
  end
end
def ip_to_monitor ( monitored_host , server_host = node ) if node [ 'nagios' ] [ 'monitoring_interface' ] && node [ 'network' ] [ "ipaddress_#{node['nagios']['monitoring_interface']}" ] node [ 'network' ] [ "ipaddress_#{node['nagios']['monitoring_interface']}" ] elsif server_host [ 'cloud' ] . nil? && monitored_host [ 'cloud' ] monitored_host [ 'cloud' ] [ 'public_ipv4' ] . include? ( '.' ) ? monitored_host [ 'cloud' ] [ 'public_ipv4' ] : monitored_host [ 'ipaddress' ] elsif server_host [ 'cloud' ] && monitored_host [ 'cloud' ] && monitored_host [ 'cloud' ] [ 'provider' ] != server_host [ 'cloud' ] [ 'provider' ] monitored_host [ 'cloud' ] [ 'public_ipv4' ] . include? ( '.' ) ? monitored_host [ 'cloud' ] [ 'public_ipv4' ] : monitored_host [ 'ipaddress' ] else monitored_host [ 'ipaddress' ] end end
decide whether to use internal or external IP addresses for this node
if the nagios server is not in the cloud, always use public IP addresses for cloud nodes.
decide whether to use internal or external IP addresses for this node if the nagios server is not in the cloud always use public IP addresses for cloud nodes .
# if interface to monitor is specified implicitly use that # if server is not in the cloud and the monitored host is # if server host is in the cloud and the monitored node is as well, but they are not on the same provider
monitored_host
<not_specific>
server_host
<not_specific>
node
<not_specific>