mirror of
https://github.com/munin-monitoring/contrib.git
synced 2025-07-21 18:41:03 +00:00
redis: fix "autoconf" to return "no" if no instances are configured
Previously it returned "yes" and empty graph with all labels having value "0". Also remove bogus "multigraph redis" line. TODO: die() in get_conn() makes this plugin to fail if any Redis instance can't be connected.
This commit is contained in:
parent
51af0be02b
commit
b392cacc4b
1 changed files with 9 additions and 5 deletions
|
@ -95,23 +95,27 @@ for (my $i = 1; $ENV{"host$i"}; $i++)
|
||||||
my $config = ( defined $ARGV[0] and $ARGV[0] eq "config" );
|
my $config = ( defined $ARGV[0] and $ARGV[0] eq "config" );
|
||||||
my $autoconf = ( defined $ARGV[0] and $ARGV[0] eq "autoconf" );
|
my $autoconf = ( defined $ARGV[0] and $ARGV[0] eq "autoconf" );
|
||||||
if ( $autoconf ) {
|
if ( $autoconf ) {
|
||||||
|
if (!%INSTANCES) {
|
||||||
|
print "no (no redis instances configured)\n";
|
||||||
|
exit 0;
|
||||||
|
}
|
||||||
my $err = '';
|
my $err = '';
|
||||||
for my $INSTANCE (keys %INSTANCES) {
|
for my $INSTANCE (keys %INSTANCES) {
|
||||||
if (! defined( $INSTANCES{$INSTANCE}{'SOCK'} ) ) {
|
if (! defined( $INSTANCES{$INSTANCE}{'SOCK'} ) ) {
|
||||||
$err .= "no (unable to connect to ".$INSTANCES{$INSTANCE}{'HOST'}."\[:". $INSTANCES{$INSTANCE}{'PORT'}."\])\n";
|
$err = "no (unable to connect to ".$INSTANCES{$INSTANCE}{'HOST'}."\[:". $INSTANCES{$INSTANCE}{'PORT'}."\])\n";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if ($err) {
|
if ($err) {
|
||||||
print $err;
|
print $err;
|
||||||
} else {
|
} else {
|
||||||
print 'yes';
|
print "yes\n";
|
||||||
}
|
}
|
||||||
exit 0;
|
exit 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
my $total = 0;
|
my $total = 0;
|
||||||
|
|
||||||
my $multi_graph_output = "multigraph redis\n";
|
my $multi_graph_output = '';
|
||||||
my $instance_graph_output = '';
|
my $instance_graph_output = '';
|
||||||
|
|
||||||
my $connected_clients = 0;
|
my $connected_clients = 0;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue