aboutsummaryrefslogtreecommitdiffstats
path: root/SiteSummary.pm
diff options
context:
space:
mode:
authorPetter Reinholdtsen <pere@hungry.com>2011-12-17 11:23:59 +0000
committerPetter Reinholdtsen <pere@hungry.com>2011-12-17 11:23:59 +0000
commit8428e441a113fa1366c7336d2cca8d05b35c4a87 (patch)
tree1db199ded3a344241544e3315b3d237a3b37f2b9 /SiteSummary.pm
parent0e39b5ea1a0f351c3d1e657095296ba28e6da5eb (diff)
downloadsitesummary-8428e441a113fa1366c7336d2cca8d05b35c4a87.tar.gz
sitesummary-8428e441a113fa1366c7336d2cca8d05b35c4a87.tar.bz2
sitesummary-8428e441a113fa1366c7336d2cca8d05b35c4a87.tar.xz
Add support for remapping hostnames for individual client entries,
to make it possible to gather Munin and Nagios status for hosts behind VPN connections and with non-unique host names.
Diffstat (limited to 'SiteSummary.pm')
-rw-r--r--SiteSummary.pm27
1 files changed, 26 insertions, 1 deletions
diff --git a/SiteSummary.pm b/SiteSummary.pm
index f2c856f..bc8271f 100644
--- a/SiteSummary.pm
+++ b/SiteSummary.pm
@@ -35,6 +35,26 @@ my $pwd = "/var/lib/sitesummary/entries"; # Path to the entries
# File for debian-edu configuration
my $debian_edu_config = "/debian-edu/config";
+# Provide mechanism to remap host names for hosts private networks
+# available via tunnels.
+
+my $hostmapfile = "/etc/sitesummary/hostmap";
+my %hostmap;
+
+sub load_hostmap {
+ if (open(my $fh, '<', $hostmapfile)) {
+ %hostmap = (); # Clear hostmap
+ while (<$fh>) {
+ chomp;
+ my ($hostid, $newhostname) = split(/;/);
+ $hostmap{$hostid} = $newhostname;
+ }
+ close $fh;
+ } else {
+ return;
+ }
+}
+
sub get_filepath_current {
my ($hostid, $file) = @_;
return "$pwd/$hostid$file";
@@ -172,7 +192,11 @@ sub get_primary_macaddress {
#
sub get_hostname {
my $hostid = shift;
- return get_file_string($hostid, "/system/hostname");
+ if (exists $hostmap{$hostid}) {
+ return $hostmap{$hostid};
+ } else {
+ return get_file_string($hostid, "/system/hostname");
+ }
}
#
@@ -389,6 +413,7 @@ sub get_age_group {
return $thisgroup;
}
+load_hostmap();
1;
########################################################################