mirror of
https://github.com/munin-monitoring/contrib.git
synced 2025-07-25 18:38:30 +00:00
Fixed undefined variable use and division by zero in redis plugin
This commit is contained in:
parent
80cb77cb31
commit
285c11cdfb
1 changed files with 11 additions and 3 deletions
|
@ -76,7 +76,9 @@ read($sock, $rep, substr($result,1)) || die "can't read from socket: $!";
|
||||||
my $hash;
|
my $hash;
|
||||||
foreach (split(/\r\n/, $rep)) {
|
foreach (split(/\r\n/, $rep)) {
|
||||||
my ($key,$val) = split(/:/, $_, 2);
|
my ($key,$val) = split(/:/, $_, 2);
|
||||||
$hash->{$key} = $val;
|
if (defined($key)) {
|
||||||
|
$hash->{$key} = $val;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
close ($sock);
|
close ($sock);
|
||||||
|
|
||||||
|
@ -136,8 +138,14 @@ switch ($0) {
|
||||||
}
|
}
|
||||||
|
|
||||||
my $total = $hash->{'keyspace_hits'} + $hash->{'keyspace_misses'};
|
my $total = $hash->{'keyspace_hits'} + $hash->{'keyspace_misses'};
|
||||||
printf("hitratio.value %.2f\n", $hash->{'keyspace_hits'} / $total * 100);
|
my $hitratio = 0;
|
||||||
printf("missratio.value %.2f\n", $hash->{'keyspace_misses'} / $total * 100);
|
my $missratio = 0;
|
||||||
|
if ($total > 0) {
|
||||||
|
$hitratio = $hash->{'keyspace_hits'} / $total * 100;
|
||||||
|
$missratio = $hash->{'keyspace_misses'} / $total * 100;
|
||||||
|
}
|
||||||
|
printf("hitratio.value %.2f\n", $hitratio);
|
||||||
|
printf("missratio.value %.2f\n", $missratio);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue