diff options
author | Petter Reinholdtsen <pere@hungry.com> | 2008-06-01 07:46:51 +0000 |
---|---|---|
committer | Petter Reinholdtsen <pere@hungry.com> | 2008-06-01 07:46:51 +0000 |
commit | 3ae0fc705695dc63214d3b18c0ef8e3fec017277 (patch) | |
tree | 2fd31d78409d8788d9d1bf3442c7c982596a73a8 | |
parent | 5db80a24a94e4361f80d591db2bb4a2e74c8d4cf (diff) | |
download | sitesummary-3ae0fc705695dc63214d3b18c0ef8e3fec017277.tar.gz sitesummary-3ae0fc705695dc63214d3b18c0ef8e3fec017277.tar.bz2 sitesummary-3ae0fc705695dc63214d3b18c0ef8e3fec017277.tar.xz |
- Use the IP address from ifconfig, not the sitesummary peer address,
when generating nagios configuration, to avoid using the web proxy IP
address.
-rw-r--r-- | SiteSummary.pm | 31 | ||||
-rw-r--r-- | debian/changelog | 3 | ||||
-rwxr-xr-x | sitesummary-nodes | 14 |
3 files changed, 29 insertions, 19 deletions
diff --git a/SiteSummary.pm b/SiteSummary.pm index c37871a..50d4fbc 100644 --- a/SiteSummary.pm +++ b/SiteSummary.pm @@ -75,14 +75,6 @@ sub get_hostclass { } # -# Return the hostname string -# -sub get_hostname { - my $hostid = shift; - return get_file_string($hostid, "/system/hostname"); -} - -# # Return the IP address on the primary network interface # sub get_primary_ip_address { @@ -106,6 +98,29 @@ sub get_primary_ip_address { } # +# Return the hostname string +# +sub get_hostname { + my $hostid = shift; + return get_file_string($hostid, "/system/hostname"); +} + +# +# Return an address that can be used to contact the host. Prefer DNS, +# but fall back to the IP address if the IP address do not resolve in +# DNS. +# +sub get_dns_address { + my $hostid = shift; + my $hostname = get_hostname($hostid); + # Use IP address as hostname if the provided hostname is bogus or + # missing in DNS. + $hostname = get_primary_ip_address($hostid) + if (! in_dns($hostname) || "localhost" eq $hostname); + return $hostname; +} + +# # Return Linux kernel version for the machines using Linux. # sub get_linux_kernel_ver { diff --git a/debian/changelog b/debian/changelog index 3c45a3a..757d253 100644 --- a/debian/changelog +++ b/debian/changelog @@ -4,6 +4,9 @@ sitesummary (0.0.38) UNRELEASED; urgency=low * Updated sitesummary-nodes: - Use IP address as hostname if the provided hostname is bogus or missing in DNS. + - Use the IP address from ifconfig, not the sitesummary peer address, + when generating nagios configuration, to avoid using the web proxy IP + address. - Ignore filesystem types autofs, binfmt_misc, iso9660, nfsd and usbfs when generating nagios checks. diff --git a/sitesummary-nodes b/sitesummary-nodes index 013be62..1dbe7d9 100755 --- a/sitesummary-nodes +++ b/sitesummary-nodes @@ -32,12 +32,8 @@ sub in_dns { sub handle_host { my $hostid = shift; - my $hostname = get_hostname($hostid); - # Use IP address as hostname if the provided hostname is bogus or - # missing in DNS. - $hostname = get_primary_ip_address($hostid) - if (! in_dns($hostname) || "localhost" eq $hostname); - $hostnames{$hostname} = $hostid; + my $address = get_dns_hostname($hostid); + $hostnames{$address} = $hostid; } sub print_list { @@ -95,11 +91,7 @@ sub generate_nagios_config { my $hostid = $hostnames{$hostname}; next unless (is_nagios_client($hostid)); - my $ifconfigpath = get_filepath_current($hostid, "/system/ifconfig-a"); - my $peerinfopath = get_filepath_current($hostid, "/peerinfo"); - open (F, "<", $peerinfopath)||die "Unable to read from $peerinfopath"; - my ($address) = split(/\s+/, scalar <F>); - close(F); + my $address = get_dns_address($hostid); # first, check ping to see if the other checks should be performed print <<EOF; |