From 965745d85c7f10579b02a4b9c9f27000d436cfd0 Mon Sep 17 00:00:00 2001 From: Dimiter 'Arruor' Nikov Date: Wed, 28 Dec 2011 22:05:47 +0200 Subject: [PATCH 1/3] Fixing issue with unused variable in check_architecture subroutine. More info available at: https://github.com/rackerhacker/MySQLTuner-perl/issues/7 --- mysqltuner.pl | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/mysqltuner.pl b/mysqltuner.pl index f61881c..0d61533 100755 --- a/mysqltuner.pl +++ b/mysqltuner.pl @@ -463,7 +463,14 @@ sub mysql_version_ge { # Checks for 32-bit boxes with more than 2GB of RAM my ($arch); sub check_architecture { - if ($doremote eq 1) { return; } + if ($doremote eq 1) { + # Setting value for $arch variable to avoid warning about uninitialized + # variable (more details at https://github.com/rackerhacker/MySQLTuner-perl/issues/7) + # $id Dimiter "Arruor" Nikov exp + $arch = 0; + return; + } + if (`uname` =~ /SunOS/ && `isainfo -b` =~ /64/) { $arch = 64; goodprint "Operating on 64-bit architecture\n"; From f75e9d039b7823eb489fbace02ebbd8c624c81c7 Mon Sep 17 00:00:00 2001 From: Dimiter 'Arruor' Nikov Date: Thu, 29 Dec 2011 21:47:13 +0200 Subject: [PATCH 2/3] New fix for issue#7 about MySQL version reckognition Adopting scop's idea to write more reliable verification of MySQL's architecture version, both for local and remote servers. --- mysqltuner.pl | 41 +++++++++++++++++++---------------------- 1 file changed, 19 insertions(+), 22 deletions(-) diff --git a/mysqltuner.pl b/mysqltuner.pl index 0d61533..3cc569f 100755 --- a/mysqltuner.pl +++ b/mysqltuner.pl @@ -463,32 +463,29 @@ sub mysql_version_ge { # Checks for 32-bit boxes with more than 2GB of RAM my ($arch); sub check_architecture { - if ($doremote eq 1) { - # Setting value for $arch variable to avoid warning about uninitialized - # variable (more details at https://github.com/rackerhacker/MySQLTuner-perl/issues/7) - # $id Dimiter "Arruor" Nikov exp - $arch = 0; - return; - } - - if (`uname` =~ /SunOS/ && `isainfo -b` =~ /64/) { + # Checking MySQL compiled version + if ($myvar{'version_compile_machine'} =~ /x86_64/) { + # We have 64-bit version of MySQL $arch = 64; - goodprint "Operating on 64-bit architecture\n"; - } elsif (`uname` !~ /SunOS/ && `uname -m` =~ /64/) { - $arch = 64; - goodprint "Operating on 64-bit architecture\n"; - } elsif (`uname` =~ /AIX/ && `bootinfo -K` =~ /64/) { - $arch = 64; - goodprint "Operating on 64-bit architecture\n"; - } else { + goodprint "Operating on 64-bit version of MySQL\n"; + } elsif ($myvar{'version_compile_machine'} =~ /i*86/) { + # We have 32-bit version of MySQL $arch = 32; + + # Check for available memory and suggest switching to + # 64-bit version of mysql if ($physical_memory > 2147483648) { - badprint "Switch to 64-bit OS - MySQL cannot currently use all of your RAM\n"; - } else { - goodprint "Operating on 32-bit architecture with less than 2GB RAM\n"; - } + badprint "Switch to 64-bit version of MySQL\n"; + badprint "MySQL cannot currently use all of your RAM\n"; + } else { + goodprint "Operating on 32-bit version of MySQL with less than 2GB RAM\n"; + } + } else { + # Unknown version or missing compile string + $arch = 0; + badprint "Operating on unknown version of MySQL\n" } -} +} #end-sub-check_architecture # Start up a ton of storage engine counts/statistics my (%enginestats,%enginecount,$fragtables); From 77d23981be7e10844b43547057967fc304a59533 Mon Sep 17 00:00:00 2001 From: Dimiter 'Arruor' Nikov Date: Fri, 30 Dec 2011 15:07:46 +0200 Subject: [PATCH 3/3] Fix for issue #7 about more reliable MySQL version reckognition. Adopting scop's idea for MySQL version check. Now should work as discussed, both for local and remote servers. --- mysqltuner.pl | 40 +++++++++++++++++++++------------------- 1 file changed, 21 insertions(+), 19 deletions(-) diff --git a/mysqltuner.pl b/mysqltuner.pl index 3cc569f..d1e75f9 100755 --- a/mysqltuner.pl +++ b/mysqltuner.pl @@ -463,28 +463,30 @@ sub mysql_version_ge { # Checks for 32-bit boxes with more than 2GB of RAM my ($arch); sub check_architecture { - # Checking MySQL compiled version - if ($myvar{'version_compile_machine'} =~ /x86_64/) { - # We have 64-bit version of MySQL + # We assume that 32-bit version is used by default + $arch = 32; + + # If version_compile_machine ends with 64 + # then we have 64-bit MySQL on non-Windows OS + if ($myvar{'version_compile_machine'} =~ /64$/) { $arch = 64; goodprint "Operating on 64-bit version of MySQL\n"; - } elsif ($myvar{'version_compile_machine'} =~ /i*86/) { - # We have 32-bit version of MySQL - $arch = 32; - - # Check for available memory and suggest switching to - # 64-bit version of mysql - if ($physical_memory > 2147483648) { - badprint "Switch to 64-bit version of MySQL\n"; - badprint "MySQL cannot currently use all of your RAM\n"; - } else { - goodprint "Operating on 32-bit version of MySQL with less than 2GB RAM\n"; - } - } else { - # Unknown version or missing compile string - $arch = 0; - badprint "Operating on unknown version of MySQL\n" + } elsif ($myvar{'version_compile_os'} =~ /64$/) { + # We have 64-bit version of MySQL on 64-bit Windows OS + $arch = 64; + goodprint "Operating on 64-bit version of MySQL\n"; } + + # Check for available memory and suggest switching to + # 64-bit version of mysql + if ($arch == 32) { + if ($physical_memory > 2147483648) { + badprint "Switch to 64-bit version of MySQL\n"; + badprint "MySQL cannot currently use all of your RAM\n"; + } else { + goodprint "Operating on 32-bit version of MySQL with less than 2GB RAM\n"; + } + } # end-if-32-bit-arch-check } #end-sub-check_architecture # Start up a ton of storage engine counts/statistics