Projet

Général

Profil

Révision 285c11cd

ID285c11cdfb1ca8cd1068a2499005e31fd7d3ef30
Parent 80cb77cb
Enfant b7e6b69b

Ajouté par iborodikhin il y a environ 13 ans

Fixed undefined variable use and division by zero in redis plugin

Voir les différences:

plugins/redis/redis_
76 76
my $hash;
77 77
foreach (split(/\r\n/, $rep)) {
78 78
    my ($key,$val) = split(/:/, $_, 2);
79
    $hash->{$key} = $val;
79
    if (defined($key)) {
80
        $hash->{$key} = $val;
81
    }
80 82
}
81 83
close ($sock);
82 84

  
......
136 138
        }
137 139
            
138 140
        my $total = $hash->{'keyspace_hits'} + $hash->{'keyspace_misses'};
139
        printf("hitratio.value %.2f\n", $hash->{'keyspace_hits'} / $total * 100);
140
        printf("missratio.value %.2f\n", $hash->{'keyspace_misses'} / $total * 100);
141
        my $hitratio = 0;
142
        my $missratio = 0;
143
        if ($total > 0) {
144
            $hitratio = $hash->{'keyspace_hits'} / $total * 100;
145
            $missratio = $hash->{'keyspace_misses'} / $total * 100;
146
        }
147
        printf("hitratio.value %.2f\n", $hitratio);
148
        printf("missratio.value %.2f\n", $missratio);
141 149
    }
142 150

  
143 151

  

Formats disponibles : Unified diff