Skip to content

Commit

Permalink
version 1.9.9 - Legibility and typos #597
Browse files Browse the repository at this point in the history
  • Loading branch information
jmrenouard committed Jun 15, 2022
1 parent 4057662 commit cf568a8
Showing 1 changed file with 42 additions and 50 deletions.
92 changes: 42 additions & 50 deletions mysqltuner.pl
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#!/usr/bin/env perl
# mysqltuner.pl - Version 1.9.8
# mysqltuner.pl - Version 1.9.9
# High Performance MySQL Tuning Script
# Copyright (C) 2006-2022 Major Hayden - major@mhtx.net
# Copyright (C) 2006-2022 Jean-Marie Renouard - jmrenouard@gmail.com
Expand Down Expand Up @@ -57,7 +57,7 @@ package main;
#use Env;

# Set up a few variables for use in the script
my $tunerversion = "1.9.8";
my $tunerversion = "1.9.9";
my ( @adjvars, @generalrec );

# Set defaults
Expand Down Expand Up @@ -190,24 +190,24 @@ package main;

# check if we need to enable verbose mode
if ( $opt{verbose} ) {
$opt{checkversion} = 1; #Check for updates to MySQLTuner
$opt{dbstat} = 1; #Print database information
$opt{tbstat} = 1; #Print database information
$opt{idxstat} = 1; #Print index information
$opt{sysstat} = 1; #Print index information
$opt{buffers} = 1; #Print global and per-thread buffer values
$opt{pfstat} = 1; #Print performance schema info.
$opt{checkversion} = 1; # Check for updates to MySQLTuner
$opt{dbstat} = 1; # Print database information
$opt{tbstat} = 1; # Print database information
$opt{idxstat} = 1; # Print index information
$opt{sysstat} = 1; # Print index information
$opt{buffers} = 1; # Print global and per-thread buffer values
$opt{pfstat} = 1; # Print performance schema info.
$opt{cvefile} = 'vulnerabilities.csv'; #CVE File for vulnerability checks
}
$opt{nocolor} = 1 if defined( $opt{outputfile} );
$opt{tbstat} = 0 if ( $opt{notbstat} == 1 ); # Don't Print table information
$opt{colstat} = 0 if ( $opt{nocolstat} == 1 ); # Don't Print column information
$opt{dbstat} = 0 if ( $opt{nodbstat} == 1 ); # Don't Print database information
$opt{noprocess} = 0
if ( $opt{noprocess} == 1 ); # Don't Print process information
if ( $opt{noprocess} == 1 ); # Don't Print process information
$opt{sysstat} = 0 if ( $opt{nosysstat} == 1 ); # Don't Print sysstat information
$opt{pfstat} = 0
if ( $opt{nopfstat} == 1 ); # Don't Print performance schema information
if ( $opt{nopfstat} == 1 ); # Don't Print performance schema information
$opt{idxstat} = 0 if ( $opt{noidxstat} == 1 ); # Don't Print index information

# for RPM distributions
Expand Down Expand Up @@ -995,7 +995,6 @@ sub mysql_setup {
exit 1;
}
}

}

# MySQL Request Array
Expand All @@ -1004,7 +1003,7 @@ sub select_array {
debugprint "PERFORM: $req ";
my @result = `$mysqlcmd $mysqllogin -Bse "\\w$req" 2>>/dev/null`;
if ( $? != 0 ) {
badprint "failed to execute: $req";
badprint "Failed to execute: $req";
badprint "FAIL Execute SQL / return code: $?";
debugprint "CMD : $mysqlcmd";
debugprint "OPTIONS: $mysqllogin";
Expand All @@ -1029,7 +1028,7 @@ sub select_one {
debugprint "PERFORM: $req ";
my $result = `$mysqlcmd $mysqllogin -Bse "\\w$req" 2>>/dev/null`;
if ( $? != 0 ) {
badprint "failed to execute: $req";
badprint "Failed to execute: $req";
badprint "FAIL Execute SQL / return code: $?";
debugprint "CMD : $mysqlcmd";
debugprint "OPTIONS: $mysqllogin";
Expand All @@ -1050,7 +1049,7 @@ sub select_one_g {
debugprint "PERFORM: $req ";
my @result = `$mysqlcmd $mysqllogin -re "\\w$req\\G" 2>>/dev/null`;
if ( $? != 0 ) {
badprint "failed to execute: $req";
badprint "Failed to execute: $req";
badprint "FAIL Execute SQL / return code: $?";
debugprint "CMD : $mysqlcmd";
debugprint "OPTIONS: $mysqllogin";
Expand Down Expand Up @@ -1377,7 +1376,7 @@ sub log_file_recommendations {
goodprint "Log file $myvar{'log_error'} exists";
my $size = ( stat $myvar{'log_error'} )[7];
infoprint "Log file: "
. $myvar{'log_error'} . "("
. $myvar{'log_error'} . " ("
. hr_bytes_rnd($size) . ")";

if ( $size > 0 ) {
Expand Down Expand Up @@ -2414,7 +2413,7 @@ sub check_storage_engines {
}
$result{'Tables'}{'Fragmented tables'} =
[ select_array
"SELECT CONCAT(CONCAT(TABLE_SCHEMA, '.'), TABLE_NAME),cast(DATA_FREE as signed) FROM information_schema.TABLES WHERE TABLE_SCHEMA NOT IN ('information_schema','performance_schema', 'mysql') AND DATA_LENGTH/1024/1024>100 AND cast(DATA_FREE as signed)*100/(DATA_LENGTH+INDEX_LENGTH+cast(DATA_FREE as signed)) > 10 AND NOT ENGINE='MEMORY' $not_innodb"
"SELECT CONCAT(CONCAT(TABLE_SCHEMA, '.'), TABLE_NAME),cast(DATA_FREE as signed) FROM information_schema.TABLES WHERE TABLE_SCHEMA NOT IN ('information_schema', 'performance_schema', 'mysql') AND DATA_LENGTH/1024/1024>100 AND cast(DATA_FREE as signed)*100/(DATA_LENGTH+INDEX_LENGTH+cast(DATA_FREE as signed)) > 10 AND NOT ENGINE='MEMORY' $not_innodb"
];
$fragtables = scalar @{ $result{'Tables'}{'Fragmented tables'} };

Expand Down Expand Up @@ -3180,7 +3179,7 @@ sub mysql_stats {
}
elsif ( $result{'Variables'}{'skip_name_resolve'} eq 'OFF' ) {
badprint
"name resolution is active : a reverse name resolution is made for each new connection and can reduce performance";
"Name resolution is active: a reverse name resolution is made for each new connection and can reduce performance";
push( @generalrec,
"Configure your accounts with ip or subnets only, then update your configuration with skip-name-resolve=1"
);
Expand Down Expand Up @@ -3481,7 +3480,6 @@ sub mysql_stats {
$mystat{'Table_open_cache_misses'} )
. " requests)";
}

}
}

Expand All @@ -3495,19 +3493,19 @@ sub mysql_stats {
. ") is in autosizing mode" );
}
elsif ( $myvar{'table_definition_cache'} < $nbtables ) {
badprint "table_definition_cache("
badprint "table_definition_cache ("
. $myvar{'table_definition_cache'}
. ") is lower than number of tables($nbtables) ";
. ") is less than number of tables ($nbtables) ";
push( @adjvars,
"table_definition_cache("
. $myvar{'table_definition_cache'} . ") > "
. $nbtables
. " or -1 (autosizing if supported)" );
}
else {
goodprint "table_definition_cache("
goodprint "table_definition_cache ("
. $myvar{'table_definition_cache'}
. ") is upper than number of tables($nbtables)";
. ") is greater than number of tables ($nbtables)";
}
}
else {
Expand Down Expand Up @@ -3738,7 +3736,7 @@ sub mysql_myisam {
sub mariadb_threadpool {
subheaderprint "ThreadPool Metrics";
# AriaDB
# MariaDB
unless ( defined $myvar{'have_threadpool'}
&& $myvar{'have_threadpool'} eq "YES" )
{
Expand Down Expand Up @@ -3988,7 +3986,7 @@ sub mysqsl_pfs {
if ( $nbL == 1 );
# Top user per io
subheaderprint "Performance schema: Top 5 user per io";
subheaderprint "Performance schema: Top 5 user per IO";
$nbL = 1;
for my $lQuery (
select_array(
Expand All @@ -4003,7 +4001,7 @@ sub mysqsl_pfs {
if ( $nbL == 1 );
# Top user per io latency
subheaderprint "Performance schema: Top 5 user per io latency";
subheaderprint "Performance schema: Top 5 user per IO latency";
$nbL = 1;
for my $lQuery (
select_array(
Expand Down Expand Up @@ -4498,7 +4496,7 @@ sub mysqsl_pfs {
if ( $nbL == 1 );
# Latest file IO by latency
subheaderprint "Performance schema: Latest FILE IO by latency";
subheaderprint "Performance schema: Latest File IO by latency";
$nbL = 1;
for my $lQuery (
select_array(
Expand All @@ -4513,7 +4511,7 @@ sub mysqsl_pfs {
if ( $nbL == 1 );
# FILE by IO read bytes
subheaderprint "Performance schema: FILE by IO read bytes";
subheaderprint "Performance schema: File by IO read bytes";
$nbL = 1;
for my $lQuery (
select_array(
Expand All @@ -4528,7 +4526,7 @@ sub mysqsl_pfs {
if ( $nbL == 1 );
# FILE by IO written bytes
subheaderprint "Performance schema: FILE by IO written bytes";
subheaderprint "Performance schema: File by IO written bytes";
$nbL = 1;
for my $lQuery (
select_array(
Expand All @@ -4543,7 +4541,7 @@ sub mysqsl_pfs {
if ( $nbL == 1 );
# file per IO total latency
subheaderprint "Performance schema: file per IO total latency";
subheaderprint "Performance schema: File per IO total latency";
$nbL = 1;
for my $lQuery (
select_array(
Expand Down Expand Up @@ -4679,7 +4677,7 @@ sub mysqsl_pfs {
if ( $nbL == 1 );
# TOP 15 most used index
subheaderprint "Performance schema: TOP 15 most modified indexes";
subheaderprint "Performance schema: Top 15 most modified indexes";
$nbL = 1;
for my $lQuery (
select_array(
Expand All @@ -4694,7 +4692,7 @@ sub mysqsl_pfs {
if ( $nbL == 1 );
# TOP 15 high read latency index
subheaderprint "Performance schema: TOP 15 high read latency index";
subheaderprint "Performance schema: Top 15 high read latency index";
$nbL = 1;
for my $lQuery (
select_array(
Expand All @@ -4709,7 +4707,7 @@ sub mysqsl_pfs {
if ( $nbL == 1 );
# TOP 15 high insert latency index
subheaderprint "Performance schema: TOP 15 most modified indexes";
subheaderprint "Performance schema: Top 15 most modified indexes";
$nbL = 1;
for my $lQuery (
select_array(
Expand All @@ -4724,7 +4722,7 @@ sub mysqsl_pfs {
if ( $nbL == 1 );
# TOP 15 high update latency index
subheaderprint "Performance schema: TOP 15 high update latency index";
subheaderprint "Performance schema: Top 15 high update latency index";
$nbL = 1;
for my $lQuery (
select_array(
Expand All @@ -4739,7 +4737,7 @@ sub mysqsl_pfs {
if ( $nbL == 1 );
# TOP 15 high delete latency index
subheaderprint "Performance schema: TOP 15 high delete latency index";
subheaderprint "Performance schema: Top 15 high delete latency index";
$nbL = 1;
for my $lQuery (
select_array(
Expand Down Expand Up @@ -4769,7 +4767,7 @@ sub mysqsl_pfs {
if ( $nbL == 1 );
# TOP 15 most used tables
subheaderprint "Performance schema: TOP 15 most modified tables";
subheaderprint "Performance schema: Top 15 most modified tables";
$nbL = 1;
for my $lQuery (
select_array(
Expand All @@ -4784,7 +4782,7 @@ sub mysqsl_pfs {
if ( $nbL == 1 );
# TOP 15 high read latency tables
subheaderprint "Performance schema: TOP 15 high read latency tables";
subheaderprint "Performance schema: Top 15 high read latency tables";
$nbL = 1;
for my $lQuery (
select_array(
Expand All @@ -4799,7 +4797,7 @@ sub mysqsl_pfs {
if ( $nbL == 1 );
# TOP 15 high insert latency tables
subheaderprint "Performance schema: TOP 15 high insert latency tables";
subheaderprint "Performance schema: Top 15 high insert latency tables";
$nbL = 1;
for my $lQuery (
select_array(
Expand All @@ -4814,7 +4812,7 @@ sub mysqsl_pfs {
if ( $nbL == 1 );
# TOP 15 high update latency tables
subheaderprint "Performance schema: TOP 15 high update latency tables";
subheaderprint "Performance schema: Top 15 high update latency tables";
$nbL = 1;
for my $lQuery (
select_array(
Expand All @@ -4829,7 +4827,7 @@ sub mysqsl_pfs {
if ( $nbL == 1 );
# TOP 15 high delete latency tables
subheaderprint "Performance schema: TOP 15 high delete latency tables";
subheaderprint "Performance schema: Top 15 high delete latency tables";
$nbL = 1;
for my $lQuery (
select_array(
Expand Down Expand Up @@ -5930,7 +5928,7 @@ sub mysql_innodb {
or $mycalc{'innodb_log_size_pct'} > 30 )
{
badprint "Ratio InnoDB log file size / InnoDB Buffer pool size ("
. $mycalc{'innodb_log_size_pct'} . " %): "
. $mycalc{'innodb_log_size_pct'} . "%): "
. hr_bytes( $myvar{'innodb_log_file_size'} ) . " * "
. $myvar{'innodb_log_files_in_group'} . "/"
. hr_bytes( $myvar{'innodb_buffer_pool_size'} )
Expand All @@ -5942,7 +5940,7 @@ sub mysql_innodb {
$myvar{'innodb_buffer_pool_size'} /
$myvar{'innodb_log_files_in_group'} / 4
)
. ") if possible, so InnoDB total log files size equals to 25% of buffer pool size."
. ") if possible, so InnoDB total log files size equals 25% of buffer pool size."
);
if ( mysql_version_le( 5, 6, 2 ) ) {
push( @generalrec,
Expand Down Expand Up @@ -6020,7 +6018,7 @@ sub mysql_innodb {
"InnoDB Buffer Pool Chunk Size not used or defined in your version";
}
else {
infoprint "Number of InnoDB Buffer Pool Chunk : "
infoprint "Number of InnoDB Buffer Pool Chunk: "
. int( $myvar{'innodb_buffer_pool_size'} ) /
int( $myvar{'innodb_buffer_pool_chunk_size'} ) . " for "
. $myvar{'innodb_buffer_pool_instances'}
Expand Down Expand Up @@ -6380,7 +6378,6 @@ sub mysql_databases {
. " table column(s) has same collation defined for all text like column(s).";
}
}
}
# Recommendations for database columns
Expand Down Expand Up @@ -6482,14 +6479,12 @@ sub mysql_tables {
"ALTER TABLE \`$dbname\`.\`$tbname\` MODIFY \`$_\` $optimal_type;"
);
}
}
else {
goodprint "$dbname.$tbname ($_) type: $current_type";
}
}
}
}
}
Expand Down Expand Up @@ -6630,7 +6625,6 @@ ()
"Skip Index metrics from information schema missing in this version";
return;
}
}
sub mysql_routines() {
Expand All @@ -6640,7 +6634,6 @@ ()
"Skip Index metrics from information schema missing in this version";
return;
}
}
sub mysql_triggers() {
Expand All @@ -6650,7 +6643,6 @@ ()
"Skip Index metrics from information schema missing in this version";
return;
}
}
# Take the two recommendation arrays and display them at the end of the output
Expand Down Expand Up @@ -6875,7 +6867,7 @@ sub which {
=head1 NAME
MySQLTuner 1.9.8 - MySQL High Performance Tuning Script
MySQLTuner 1.9.9 - MySQL High Performance Tuning Script
=head1 IMPORTANT USAGE GUIDELINES
Expand Down

0 comments on commit cf568a8

Please sign in to comment.