aboutsummaryrefslogtreecommitdiffstats
path: root/sitesummary-nodes
diff options
context:
space:
mode:
authorPetter Reinholdtsen <pere@hungry.com>2011-12-24 05:27:58 +0000
committerPetter Reinholdtsen <pere@hungry.com>2011-12-24 05:27:58 +0000
commitdd16d2508f8660cd55abe365ffc0a232c487100c (patch)
treebe1ed09d7781cf1d6e7a22e447e6982d88b0ff50 /sitesummary-nodes
parent42459853003bd47a1e4eeb5fc85874a8222637b0 (diff)
downloadsitesummary-dd16d2508f8660cd55abe365ffc0a232c487100c.tar.gz
sitesummary-dd16d2508f8660cd55abe365ffc0a232c487100c.tar.bz2
sitesummary-dd16d2508f8660cd55abe365ffc0a232c487100c.tar.xz
Rewrite code to recognise a remote Nagios client to use host ID
to allow a Nagios server to be another Nagios servers client.
Diffstat (limited to 'sitesummary-nodes')
-rwxr-xr-xsitesummary-nodes19
1 files changed, 14 insertions, 5 deletions
diff --git a/sitesummary-nodes b/sitesummary-nodes
index e8695ac..7438e3d 100755
--- a/sitesummary-nodes
+++ b/sitesummary-nodes
@@ -9,6 +9,7 @@ use warnings;
use SiteSummary;
use Getopt::Std;
use Socket;
+use File::Temp qw(tempfile);
sub usage {
print <<EOF;
@@ -21,7 +22,7 @@ Usage: $0 [-hmnw]
EOF
}
-# Idea for way to provide overrides for the functions in this script
+# Idea for way to provide overrides for the functions in this script
#eval 'require "/etc/sitesummary/sitesummary-nodes-override"';
#if ($@ && $@ !~ qr{^Can't locate /etc/sitesummary/sitesummary-nodes-override}) {
# die $@;
@@ -31,6 +32,8 @@ my %opts;
getopts("hmnw", \%opts) || (usage(), exit(1));
my %hostnames;
+my $server_hostid = get_localhost_hostid() ||
+ die "Unable to figure out hostid for the local host";
for_all_hosts(\&handle_host);
@@ -60,6 +63,14 @@ sub print_list {
}
}
+sub get_localhost_hostid {
+ my ($fh, $filename) = tempfile();
+ `/sbin/ifconfig -a > $filename`;
+ my $localhost_hostid = get_unique_ether_id($filename);
+ unlink $filename;
+ return $localhost_hostid;
+}
+
# Get an IP address, try to resolve it in DNS , and return the IP
# address if no DNS reverse entry was found.
sub get_dnsnameorip {
@@ -107,10 +118,8 @@ sub print_ip_hw_list {
sub is_remote_nagios_client {
my $hostid = shift;
- return is_pkg_installed($hostid, "nagios-nrpe-server") && !
- (is_pkg_installed($hostid, "nagios-text") ||
- is_pkg_installed($hostid, "nagios2") ||
- is_pkg_installed($hostid, "nagios3"));
+ return is_pkg_installed($hostid, "nagios-nrpe-server") &&
+ $server_hostid ne $hostid;
}
# Return information about the switches connected to a given host, as