Skip to content

Commit

Permalink
Minor fix if no selects have been run (Thanks Kevin)
Browse files Browse the repository at this point in the history
  • Loading branch information
major committed Aug 15, 2007
1 parent efc984f commit 44f465a
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions mysqltuner.pl
Expand Up @@ -147,8 +147,9 @@ sub mysql_setup {
}
}

my (%mystat,%myvar);
my (%mystat,%myvar,$dummyselect);
sub get_all_vars {
$dummyselect = `mysql $mysqllogin -Bse "SELECT VERSION();"`;
my @mysqlvarlist = `mysql $mysqllogin -Bse "SHOW /*!50000 GLOBAL */ VARIABLES;"`;
foreach my $line (@mysqlvarlist) {
$line =~ /([a-zA-Z_]*)\s*(.*)/;
Expand Down Expand Up @@ -285,9 +286,9 @@ sub calculations {
if ($mysqlvermajor > 3) {
$mycalc{'query_cache_efficiency'} = sprintf("%.1f",($mystat{'Qcache_hits'} / ($mystat{'Com_select'} + $mystat{'Qcache_hits'})) * 100);
if ($myvar{'query_cache_size'}) {
$mycalc{'pct_query_cache_used'} = sprintf("%.1f",100 - ($mystat{'Qcache_free_memory'} / $myvar{'query_cache_size'}) * 100);
$mycalc{'pct_query_cache_used'} = sprintf("%.1f",100 - ($mystat{'Qcache_free_memory'} / $myvar{'query_cache_size'}) * 100);
}
if ($mystat{'Qcache_lowmem_prunes'} == 0) {
if ($mystat{'Qcache_lowmem_prunes'} == 0) {
$mycalc{'query_cache_prunes_per_day'} = 0;
} else {
$mycalc{'query_cache_prunes_per_day'} = int($mystat{'Qcache_lowmem_prunes'} / ($mystat{'Uptime'}/86400));
Expand Down

0 comments on commit 44f465a

Please sign in to comment.