aboutsummaryrefslogtreecommitdiffstats
path: root/SiteSummary.pm
diff options
context:
space:
mode:
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 {