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 | |
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.
-rw-r--r-- | README | 30 | ||||
-rw-r--r-- | SiteSummary.pm | 27 | ||||
-rw-r--r-- | debian/changelog | 9 |
3 files changed, 59 insertions, 7 deletions
@@ -28,12 +28,12 @@ to enable Munin autoconfig on the sitesummary collector Sitesummary generated Nagios configuration ------------------------------------------ -Since version 0.0.51, there is experimental code in sitesummary to -generate Nagios configuration based on the collected information. To -enable this, install nagios3 and nagios-plugins-standard, edit -/etc/default/nagios3 to include -'NAGIOSCFG=/etc/nagios3/sitesummary.cfg' and run the sitesummary cron -job. Running these commands as root normally does the trick. +Since version 0.0.51, there is code in sitesummary to generate Nagios +configuration based on the collected information. To enable this, +install nagios3 and nagios-plugins-standard, edit /etc/default/nagios3 +to include 'NAGIOSCFG=/etc/nagios3/sitesummary.cfg' and run the +sitesummary cron job. Running these commands as root normally does +the trick. aptitude install nagios3 nagios-plugins-standard echo 'NAGIOSCFG="/etc/nagios3/sitesummary.cfg"' >> /etc/default/nagios3 @@ -70,6 +70,24 @@ to query Nagios NRPE on the clients. sitesummary-client sitesummary-client/nagios-server string sitesummary sitesummary-client sitesummary-client/enable-nagios-nrpe-config boolean true +Handling hosts behind VPN connections +------------------------------------- + +To handle hosts with hostnames missing in DNS or IP adresses not +available directly from the Nagios and Munin server, a mechanism to +map entries to new hostnames is provided. + +To enable it, create a file /etc/sitesummary/hostmap with content like this + + ether-AA:BB:CC:DD:EE:FF new-name + +The ether-* name is the host entry name from +/var/lib/sitesummary/entries/, and the new-name entry is the hostname +to use instead of the value in system/hostname. + +For this to work, the new-name entry must map to a IP address, either +in DNS via an entry in /etc/hosts. + Design draft ------------ system to collect key info about all the machines on a site, to help 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; ######################################################################## diff --git a/debian/changelog b/debian/changelog index 5aecc56..d09168b 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,3 +1,12 @@ +sitesummary (0.0.72~test0) UNRELEASED; urgency=low + + [ Petter Reinholdtsen ] + * 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. + + -- Petter Reinholdtsen <pere@debian.org> Sat, 17 Dec 2011 12:06:31 +0100 + sitesummary (0.0.71) unstable; urgency=low * Make sure 'site-summary -l' report handle hosts without a site set. |