Assembla home | Assembla project page
 

Changeset 35

Show
Ignore:
Timestamp:
04/06/08 15:17:10 (8 months ago)
Author:
major
Message:

Version bump to 0.9.0
Fixed a bug where NULL may appear when enumerating tables on MySQL 5
MySQLTuner now checks for updates and allows the checks to be disabled

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • mysqltuner.pl

    r34 r35  
    11#!/usr/bin/perl -w 
    2 # mysqltuner.pl - Version 0.8.9 
     2# mysqltuner.pl - Version 0.9.0 
    33# High Performance MySQL Tuning Script 
    44# Copyright (C) 2006-2008 Major Hayden - major@mhtx.net 
     
    3838 
    3939# Set up a few variables for use in the script 
    40 my $tunerversion = "0.8.9"; 
     40my $tunerversion = "0.9.0"; 
    4141my (@adjvars, @generalrec); 
    4242 
     
    4848                "nocolor" => 0, 
    4949                "skipsize" => 0, 
     50                "skipversion" => 0, 
    5051        ); 
    5152         
     
    5758                'nocolor', 
    5859                'skipsize', 
     60                'skipversion', 
    5961                'help', 
    6062        ); 
     
    7476                "   Performance and Reporting Options\n". 
    7577                "      --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". 
    7780                "   Output Options:\n". 
    7881                "      --nogood         Remove OK responses\n". 
     
    250253} 
    251254 
     255# Checks for updates to MySQLTuner 
     256sub 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 
    252279# Checks for supported or EOL'ed MySQL versions 
    253280my ($mysqlvermajor,$mysqlverminor); 
    254281sub validate_mysql_version { 
    255         print "\n-------- General Statistics --------------------------------------------------\n"; 
    256282        ($mysqlvermajor,$mysqlverminor) = $myvar{'version'} =~ /(\d)\.(\d)/; 
    257283        if ($mysqlvermajor < 5) { 
     
    300326        if ($mysqlvermajor eq 5) { 
    301327                # 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;"`; 
    303329                foreach my $line (@templist) { 
    304330                        my ($engine,$size,$count); 
     
    714740mysql_setup;                                    # Gotta login first 
    715741get_all_vars;                                   # Toss variables/status into hashes 
     742validate_tuner_version;                 # Check current MySQLTuner version 
    716743validate_mysql_version;                 # Check current MySQL version 
    717744check_architecture;                             # Suggest 64-bit upgrade