mirror of
https://github.com/munin-monitoring/contrib.git
synced 2025-07-22 14:16:00 +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] : '';
|
my $cmd = (defined($ARGV[0])) ? $ARGV[0] : '';
|
||||||
|
|
||||||
if ($cmd eq 'config') {
|
|
||||||
my @hosts = ();
|
my @hosts = ();
|
||||||
open(my $conf, "<", $configfile);
|
open(my $conf, "<", $configfile) or die "can't open $configfile: $!";
|
||||||
my $content = join("", <$conf>);
|
my $content = join("", <$conf>);
|
||||||
while ( $content =~ /table\s*<([^>]*)>\s*{([^}]*)}/g) {
|
while ( $content =~ /table\s*<([^>]*)>\s*{([^}]*)}/g) {
|
||||||
my $hosts = $2;
|
my $hosts = $2;
|
||||||
$hosts =~ s/#.*$//mg;
|
$hosts =~ s/#.*$//mg; # comments
|
||||||
@hosts = split /\s+/, $hosts;
|
$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("multigraph relayd_avail\n\n");
|
||||||
print("graph_title Relayd host availability\n");
|
print("graph_title Relayd host availability\n");
|
||||||
print("graph_args --lower-limit 0\n");
|
print("graph_args --lower-limit 0\n");
|
||||||
|
@ -126,11 +129,11 @@ while (<$log>) {
|
||||||
close($log) or warn "failed to close pipe: $!";
|
close($log) or warn "failed to close pipe: $!";
|
||||||
|
|
||||||
print "multigraph relayd_avail\n\n";
|
print "multigraph relayd_avail\n\n";
|
||||||
for my $host (keys %avail) {
|
for my $host (@hosts) {
|
||||||
print "$host.value " . $avail{$host} . "\n";
|
print "$host.value " . ($avail{$host} || 'NaN'). "\n";
|
||||||
}
|
}
|
||||||
|
|
||||||
print "\nmultigraph relayd_incidents\n\n";
|
print "\nmultigraph relayd_incidents\n\n";
|
||||||
for my $host (keys %down) {
|
for my $host (@hosts) {
|
||||||
print "$host.value " . $down{$host} . "\n";
|
print "$host.value " . ($down{$host} || 0). "\n";
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue