diff options
-rwxr-xr-x | sitesummary-nodes | 12 |
1 files changed, 10 insertions, 2 deletions
diff --git a/sitesummary-nodes b/sitesummary-nodes index e31e4f9..e9506a8 100755 --- a/sitesummary-nodes +++ b/sitesummary-nodes @@ -86,6 +86,15 @@ sub get_default_route { return undef; } +# Get an IP address, try to resolve it in DNS , and return the IP +# address if no DNS reverse entry was found. +sub get_dnsnameorip { + my $ipaddr = shift; + my $resolved; + $resolved = gethostbyaddr(inet_aton($ipaddr), AF_INET); + return $resolved || $ipaddr; +} + sub is_munin_client { my $hostid = shift; return is_pkg_installed($hostid, "munin-node"); @@ -187,8 +196,7 @@ sub generate_nagios_config { # Only check laptops that have the nagios tools installed next if is_laptop($hostid) && ! $remote; - my $defaultroute = gethostbyaddr(inet_aton(get_default_route($hostid)), - AF_INET); + my $defaultroute = get_dnsnameorip(get_default_route($hostid)); # Also check default route host if (defined $defaultroute && !exists $hosts{$defaultroute}) { |