blob: 1c3b0df410cd62047fbc86db386b0d06945a69de (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
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
}
}
|