aboutsummaryrefslogtreecommitdiffstats
path: root/SiteSummary.pm
diff options
context:
space:
mode:
authorPetter Reinholdtsen <pere@hungry.com>2008-06-01 07:46:51 +0000
committerPetter Reinholdtsen <pere@hungry.com>2008-06-01 07:46:51 +0000
commit3ae0fc705695dc63214d3b18c0ef8e3fec017277 (patch)
tree2fd31d78409d8788d9d1bf3442c7c982596a73a8 /SiteSummary.pm
parent5db80a24a94e4361f80d591db2bb4a2e74c8d4cf (diff)
downloadsitesummary-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.
Diffstat (limited to 'SiteSummary.pm')
-rw-r--r--SiteSummary.pm31
1 files changed, 23 insertions, 8 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 {