diff options
author | Petter Reinholdtsen <pere@hungry.com> | 2011-12-17 11:23:59 +0000 |
---|---|---|
committer | Petter Reinholdtsen <pere@hungry.com> | 2011-12-17 11:23:59 +0000 |
commit | 8428e441a113fa1366c7336d2cca8d05b35c4a87 (patch) | |
tree | 1db199ded3a344241544e3315b3d237a3b37f2b9 /SiteSummary.pm | |
parent | 0e39b5ea1a0f351c3d1e657095296ba28e6da5eb (diff) | |
download | sitesummary-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.pm | 27 |
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; ######################################################################## |