mirror of
https://github.com/munin-monitoring/contrib.git
synced 2025-07-22 02:51:03 +00:00
use parsed hosts all the time
This commit is contained in:
parent
97fd896837
commit
99df8a0ed1
1 changed files with 15 additions and 12 deletions
|
@ -65,15 +65,18 @@ my $configfile = "/usr/local/etc/relayd.conf";
|
|||
|
||||
my $cmd = (defined($ARGV[0])) ? $ARGV[0] : '';
|
||||
|
||||
if ($cmd eq 'config') {
|
||||
my @hosts = ();
|
||||
open(my $conf, "<", $configfile);
|
||||
my $content = join("", <$conf>);
|
||||
while ( $content =~ /table\s*<([^>]*)>\s*{([^}]*)}/g) {
|
||||
my @hosts = ();
|
||||
open(my $conf, "<", $configfile) or die "can't open $configfile: $!";
|
||||
my $content = join("", <$conf>);
|
||||
while ( $content =~ /table\s*<([^>]*)>\s*{([^}]*)}/g) {
|
||||
my $hosts = $2;
|
||||
$hosts =~ s/#.*$//mg;
|
||||
@hosts = split /\s+/, $hosts;
|
||||
}
|
||||
$hosts =~ s/#.*$//mg; # comments
|
||||
$hosts =~ s/^\s+//mg; # trim spaces before lines
|
||||
print "table $1: $hosts\n" if defined $ENV{MUNIN_DEBUG};
|
||||
push @hosts , split /\s+/, $hosts;
|
||||
}
|
||||
|
||||
if ($cmd eq 'config') {
|
||||
print("multigraph relayd_avail\n\n");
|
||||
print("graph_title Relayd host availability\n");
|
||||
print("graph_args --lower-limit 0\n");
|
||||
|
@ -126,11 +129,11 @@ while (<$log>) {
|
|||
close($log) or warn "failed to close pipe: $!";
|
||||
|
||||
print "multigraph relayd_avail\n\n";
|
||||
for my $host (keys %avail) {
|
||||
print "$host.value " . $avail{$host} . "\n";
|
||||
for my $host (@hosts) {
|
||||
print "$host.value " . ($avail{$host} || 'NaN'). "\n";
|
||||
}
|
||||
|
||||
print "\nmultigraph relayd_incidents\n\n";
|
||||
for my $host (keys %down) {
|
||||
print "$host.value " . $down{$host} . "\n";
|
||||
for my $host (@hosts) {
|
||||
print "$host.value " . ($down{$host} || 0). "\n";
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue