aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPetter Reinholdtsen <pere@hungry.com>2010-01-18 08:02:57 +0000
committerPetter Reinholdtsen <pere@hungry.com>2010-01-18 08:02:57 +0000
commit166bac1701abc2a92f0de4819d36d2b20bb96da6 (patch)
treef6ee3cef3e1f548c5566e1dc8eccaf06301477c6
parent9141927b26903077c8db88f0e0e0e8eb97e99658 (diff)
downloadsitesummary-166bac1701abc2a92f0de4819d36d2b20bb96da6.tar.gz
sitesummary-166bac1701abc2a92f0de4819d36d2b20bb96da6.tar.bz2
sitesummary-166bac1701abc2a92f0de4819d36d2b20bb96da6.tar.xz
Check default route ping even if it is missing in DNS.
-rwxr-xr-xsitesummary-nodes12
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}) {