Changeset 35
- Timestamp:
- 04/06/08 15:17:10 (8 months ago)
- Files:
-
- mysqltuner.pl (modified) (8 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
mysqltuner.pl
r34 r35 1 1 #!/usr/bin/perl -w 2 # mysqltuner.pl - Version 0. 8.92 # mysqltuner.pl - Version 0.9.0 3 3 # High Performance MySQL Tuning Script 4 4 # Copyright (C) 2006-2008 Major Hayden - major@mhtx.net … … 38 38 39 39 # Set up a few variables for use in the script 40 my $tunerversion = "0. 8.9";40 my $tunerversion = "0.9.0"; 41 41 my (@adjvars, @generalrec); 42 42 … … 48 48 "nocolor" => 0, 49 49 "skipsize" => 0, 50 "skipversion" => 0, 50 51 ); 51 52 … … 57 58 'nocolor', 58 59 'skipsize', 60 'skipversion', 59 61 'help', 60 62 ); … … 74 76 " Performance and Reporting Options\n". 75 77 " --skipsize Don't enumerate tables and their types/sizes\n". 76 " (Recommended for servers with many tables)\n\n". 78 " (Recommended for servers with many tables)\n". 79 " --skipversion Don't check for updates to MySQLTuner\n\n". 77 80 " Output Options:\n". 78 81 " --nogood Remove OK responses\n". … … 250 253 } 251 254 255 # Checks for updates to MySQLTuner 256 sub validate_tuner_version { 257 print "\n-------- General Statistics --------------------------------------------------\n"; 258 if ($opt{skipversion} eq 1) { 259 infoprint "Skipped version check for MySQLTuner script\n"; 260 return; 261 } 262 my $update; 263 if (-e "/usr/bin/curl") { 264 $update = `/usr/bin/curl --connect-timeout 5 http://mysqltuner.com/versioncheck.php?v=$tunerversion 2>/dev/null`; 265 chomp($update); 266 } elsif (-e "/usr/bin/wget") { 267 $update = `/usr/bin/wget -T 5 -O - http://mysqltuner.com/versioncheck.php?v=$tunerversion 2>/dev/null`; 268 chomp($update); 269 } 270 if ($update eq 1) { 271 badprint "There is a new version of MySQLTuner available\n"; 272 } elsif ($update eq 0) { 273 goodprint "You have the latest version of MySQLTuner\n"; 274 } else { 275 infoprint "Unable to check for the latest MySQLTuner version\n"; 276 } 277 } 278 252 279 # Checks for supported or EOL'ed MySQL versions 253 280 my ($mysqlvermajor,$mysqlverminor); 254 281 sub validate_mysql_version { 255 print "\n-------- General Statistics --------------------------------------------------\n";256 282 ($mysqlvermajor,$mysqlverminor) = $myvar{'version'} =~ /(\d)\.(\d)/; 257 283 if ($mysqlvermajor < 5) { … … 300 326 if ($mysqlvermajor eq 5) { 301 327 # MySQL 5 servers can have table sizes calculated quickly from information schema 302 my @templist = `mysql $mysqllogin -Bse "SELECT ENGINE,SUM(DATA_LENGTH),COUNT(ENGINE) FROM information_schema.TABLES WHERE TABLE_SCHEMA NOT IN ('information_schema','mysql') GROUP BY ENGINE ORDER BY ENGINE ASC;"`;328 my @templist = `mysql $mysqllogin -Bse "SELECT ENGINE,SUM(DATA_LENGTH),COUNT(ENGINE) FROM information_schema.TABLES WHERE TABLE_SCHEMA NOT IN ('information_schema','mysql') GROUP BY ENGINE HAVING SUM(DATA_LENGTH) > 0 ORDER BY ENGINE ASC;"`; 303 329 foreach my $line (@templist) { 304 330 my ($engine,$size,$count); … … 714 740 mysql_setup; # Gotta login first 715 741 get_all_vars; # Toss variables/status into hashes 742 validate_tuner_version; # Check current MySQLTuner version 716 743 validate_mysql_version; # Check current MySQL version 717 744 check_architecture; # Suggest 64-bit upgrade