Assembla home | Assembla project page
 

Changeset 11

Show
Ignore:
Timestamp:
08/03/07 01:55:56 (1 year ago)
Author:
major
Message:

Added explanations for key max_connections and fixed a Plesk bug when you run the script as a non-root user

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • mysqltuner.pl

    r10 r11  
    137137my $mysqllogin; 
    138138sub setup_mysql_login { 
    139     if ( -f "/etc/psa/.psa.shadow" ) { 
     139    if ( -r "/etc/psa/.psa.shadow" ) { 
    140140        # It's a Plesk box, use the available credentials 
    141141        $mysqllogin = "-u admin -p`cat /etc/psa/.psa.shadow`"; 
    142142        my $loginstatus = `mysqladmin ping $mysqllogin 2>&1`; 
    143143        if ($loginstatus =~ /mysqld is alive/) { 
    144             goodprint "Successfully logged into MySQL using Plesk's credentials.\n"; 
     144            # Login was successful, but we won't say anything to save space 
    145145            return 1; 
    146146        } else { 
     
    160160                # Login was successful, but we won't say anything to save space 
    161161            } else { 
    162                 #badprint "Successfully authenticated with no password - SECURITY RISK!\n"; 
    163162                badprint "Successfully authenticated with no password - SECURITY RISK!\n"; 
    164163            } 
     
    176175            my $loginstatus = `mysqladmin ping $mysqllogin 2>&1`; 
    177176            if ($loginstatus =~ /mysqld is alive/) { 
    178                 print "\n".$good." Successfully logged into MySQL using provided credentials.\n"; 
     177                # Login was successful, but we won't say anything to save space 
     178                print "\n"; 
    179179                return 1; 
    180180            } else { 
     
    289289    # 
    290290    # PER-THREAD BUFFERS: 
    291     #   binlog_cache_size - only if log_bin is 'ON' (default 32K) 
    292     my $binlog_cache_size = ($myvar{'log_bin'} =~ /ON/) ? $myvar{'binlog_cache_size'} : 0 ; 
    293291    #   join_buffer_size - helps joins that don't use indexes (default 128M) 
    294292    my $join_buffer_size = $myvar{'join_buffer_size'}; 
     
    303301    # 
    304302    # PER-THREAD BUFFER CALCULATIONS: 
    305     my $thread_buffers = $read_buffer_size + $read_rnd_buffer_size + $sort_buffer_size + $thread_stack + $join_buffer_size + $binlog_cache_size
     303    my $thread_buffers = $read_buffer_size + $read_rnd_buffer_size + $sort_buffer_size + $thread_stack + $join_buffer_size
    306304    my $total_thread_buffers = $thread_buffers * $myvar{'max_connections'}; 
    307305    my $max_thread_buffers = $thread_buffers * $mystat{'Max_used_connections'}; 
     
    349347            ") of physical memory (".hr_bytes($physical_memory).")\n"; 
    350348        $exptext = "Your current memory settings are reasonable as they do not exceed the maximum amount of memory on ". 
    351             "your server.  If you find that this script suggests increasing buffers in later tests, you have additional memory ". 
     349            "your server.  If you find that this script suggests increasing buffers in later tests, you may not have additional memory ". 
    352350            "available for the expansion of those buffers."; 
    353351    } 
     
    408406            "(".$mystat{'Max_used_connections'}."/".$myvar{'max_connections'}.")". 
    409407            " - Increase the max_connections variable\n"; 
     408            $exptext = "Your historical connection usage is too high relative to your set maximum.  The max_connections variable should be increased."; 
    410409    } elsif ($connpct < 10) { 
    411410        badprint "$connpct% of connections have been used ". 
    412411            "(".$mystat{'Max_used_connections'}."/".$myvar{'max_connections'}.")". 
    413412            " - Reduce max_connections\n"; 
     413            $exptext = "Your historical connection usage is voo low relative to your set maximum.  MySQL is wasting resources by allowing". 
     414                " so many concurrent connections."; 
    414415    } else { 
    415416        goodprint "$connpct% of connections have been used ". 
    416417            "(".$mystat{'Max_used_connections'}."/".$myvar{'max_connections'}.")\n"; 
     418            $exptext = "These settings are appropriate for your historical usage."; 
    417419    } 
    418420    # If the back_log is less than 50, there's a chance that connections will be forcefully rejected 
     
    422424        goodprint "Your listen queue back_log is set to a reasonable level (".$myvar{'back_log'}.")\n"; 
    423425    } 
     426    explainprint "You can currently handle ".($myvar{'max_connections'}+$myvar{'back_log'})." total connections, which includes ". 
     427        $myvar{'max_connections'}." active connections with ".$myvar{'back_log'}." more in queue. ".$exptext; 
    424428} 
    425429