diff options
author | Petter Reinholdtsen <pere@hungry.com> | 2007-05-20 15:47:21 +0000 |
---|---|---|
committer | Petter Reinholdtsen <pere@hungry.com> | 2007-05-20 15:47:21 +0000 |
commit | 2b69ed92dfd4f48612890cb2fe189d17075e2904 (patch) | |
tree | c42c9b6263fe00d5933f5524c850cc279dda2fdc /sitesummary-nodes | |
parent | 4e61781b4575c33b56e1589ffef620b070c9b0ce (diff) | |
download | sitesummary-2b69ed92dfd4f48612890cb2fe189d17075e2904.tar.gz sitesummary-2b69ed92dfd4f48612890cb2fe189d17075e2904.tar.bz2 sitesummary-2b69ed92dfd4f48612890cb2fe189d17075e2904.tar.xz |
[ Petter Reinholdtsen ]
* New perl function get_hostname() available from the SiteSummary
perl module.
* Add script sitesummary-nodes to list all reporting nodes. Use -m
to list them in the format expected in /etc/munin/munin.conf.
Diffstat (limited to 'sitesummary-nodes')
-rwxr-xr-x | sitesummary-nodes | 50 |
1 files changed, 50 insertions, 0 deletions
diff --git a/sitesummary-nodes b/sitesummary-nodes new file mode 100755 index 0000000..1c3b0df --- /dev/null +++ b/sitesummary-nodes @@ -0,0 +1,50 @@ +#!/usr/bin/perl +# +# Generate list of nodes to load from /etc/munin/munin.conf to check +# all the machines reporting to sitesummary. + +use strict; +use warnings; + +use SiteSummary; +use Getopt::Std; + +my %opts; +getopts("m", \%opts); + +my %hostnames; + +for_all_hosts(\&handle_host); + +if ($opts{'m'}) { + print_munin_list(); +} else { + print_list(); +} + +sub handle_host { + my $hostid = shift; + my $hostname = get_hostname($hostid); + $hostnames{$hostname} = 1; +} + +sub print_list { + for my $hostname (sort keys %hostnames) { + print "$hostname\n"; + } +} + +sub print_munin_list { + for my $hostname (sort keys %hostnames) { + + # Using hostname as address, to avoid hardcoding IP addresses in + # the file. Might be an idea to fetch the IP address from + # system/ifconfig-a + print <<EOF; +[$hostname] + address $hostname + use_node_name yes + +EOF + } +} |