Indenting mysqltuner at 2024-07-15T22:41:49+02:00
This commit is contained in:
parent
def7f81455
commit
13d2783348
1 changed files with 63 additions and 53 deletions
116
mysqltuner.pl
116
mysqltuner.pl
|
@ -215,7 +215,7 @@ $opt{dbgpattern} = '.*' if ( $opt{dbgpattern} eq '' );
|
||||||
# Activate debug variables
|
# Activate debug variables
|
||||||
#if ( $opt{debug} ne '' ) { $opt{debug} = 2; }
|
#if ( $opt{debug} ne '' ) { $opt{debug} = 2; }
|
||||||
# Activate experimental calculations and analysis
|
# Activate experimental calculations and analysis
|
||||||
#if ( $opt{experimental} ne '' ) { $opt{experimental} = 1; }
|
#if ( $opt{experimental} ne '' ) { $opt{experimental} = 1; }
|
||||||
|
|
||||||
# check if we need to enable verbose mode
|
# check if we need to enable verbose mode
|
||||||
if ( $opt{feature} ne '' ) { $opt{verbose} = 1; }
|
if ( $opt{feature} ne '' ) { $opt{verbose} = 1; }
|
||||||
|
@ -595,7 +595,8 @@ sub os_setup {
|
||||||
chomp($physical_memory);
|
chomp($physical_memory);
|
||||||
chomp($swap_memory);
|
chomp($swap_memory);
|
||||||
chomp($os);
|
chomp($os);
|
||||||
$physical_memory=$opt{forcemem} if (defined($opt{forcemem}) and $opt{forcemem} gt 0);
|
$physical_memory = $opt{forcemem}
|
||||||
|
if ( defined( $opt{forcemem} ) and $opt{forcemem} gt 0 );
|
||||||
$result{'OS'}{'OS Type'} = $os;
|
$result{'OS'}{'OS Type'} = $os;
|
||||||
$result{'OS'}{'Physical Memory'}{'bytes'} = $physical_memory;
|
$result{'OS'}{'Physical Memory'}{'bytes'} = $physical_memory;
|
||||||
$result{'OS'}{'Physical Memory'}{'pretty'} = hr_bytes($physical_memory);
|
$result{'OS'}{'Physical Memory'}{'pretty'} = hr_bytes($physical_memory);
|
||||||
|
@ -2055,27 +2056,28 @@ sub system_recommendations {
|
||||||
infoprint "User process except mysqld used "
|
infoprint "User process except mysqld used "
|
||||||
. hr_bytes_rnd($omem) . " RAM.";
|
. hr_bytes_rnd($omem) . " RAM.";
|
||||||
if ( ( 0.15 * $physical_memory ) < $omem ) {
|
if ( ( 0.15 * $physical_memory ) < $omem ) {
|
||||||
if ( $opt{nondedicated}) {
|
if ( $opt{nondedicated} ) {
|
||||||
infoprint "No warning with --nondedicated option";
|
infoprint "No warning with --nondedicated option";
|
||||||
infoprint
|
infoprint
|
||||||
"Other user process except mysqld used more than 15% of total physical memory "
|
"Other user process except mysqld used more than 15% of total physical memory "
|
||||||
. percentage( $omem, $physical_memory ) . "% ("
|
. percentage( $omem, $physical_memory ) . "% ("
|
||||||
. hr_bytes_rnd($omem) . " / "
|
. hr_bytes_rnd($omem) . " / "
|
||||||
. hr_bytes_rnd($physical_memory) . ")";
|
. hr_bytes_rnd($physical_memory) . ")";
|
||||||
} else {
|
}
|
||||||
|
else {
|
||||||
|
|
||||||
badprint
|
badprint
|
||||||
"Other user process except mysqld used more than 15% of total physical memory "
|
"Other user process except mysqld used more than 15% of total physical memory "
|
||||||
. percentage( $omem, $physical_memory ) . "% ("
|
. percentage( $omem, $physical_memory ) . "% ("
|
||||||
. hr_bytes_rnd($omem) . " / "
|
. hr_bytes_rnd($omem) . " / "
|
||||||
. hr_bytes_rnd($physical_memory) . ")";
|
. hr_bytes_rnd($physical_memory) . ")";
|
||||||
push( @generalrec,
|
push( @generalrec,
|
||||||
"Consider stopping or dedicate server for additional process other than mysqld."
|
"Consider stopping or dedicate server for additional process other than mysqld."
|
||||||
);
|
);
|
||||||
push( @adjvars,
|
push( @adjvars,
|
||||||
"DON'T APPLY SETTINGS BECAUSE THERE ARE TOO MANY PROCESSES RUNNING ON THIS SERVER. OOM KILL CAN OCCUR!"
|
"DON'T APPLY SETTINGS BECAUSE THERE ARE TOO MANY PROCESSES RUNNING ON THIS SERVER. OOM KILL CAN OCCUR!"
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
infoprint
|
infoprint
|
||||||
|
@ -3234,12 +3236,14 @@ sub calculations {
|
||||||
$mystat{'Innodb_buffer_pool_pages_total'}
|
$mystat{'Innodb_buffer_pool_pages_total'}
|
||||||
) if defined $mystat{'Innodb_buffer_pool_pages_total'};
|
) if defined $mystat{'Innodb_buffer_pool_pages_total'};
|
||||||
|
|
||||||
my $lreq= "select ROUND( 100* sum(allocated)/ ".
|
my $lreq =
|
||||||
$myvar{'innodb_buffer_pool_size'} .
|
"select ROUND( 100* sum(allocated)/ "
|
||||||
',1) FROM sys.x\$innodb_buffer_stats_by_table;';
|
. $myvar{'innodb_buffer_pool_size'}
|
||||||
debugprint("lreq: $lreq");
|
. ',1) FROM sys.x\$innodb_buffer_stats_by_table;';
|
||||||
$mycalc{'innodb_buffer_alloc_pct'} = select_one( $lreq )
|
debugprint("lreq: $lreq");
|
||||||
if ($opt{experimental});
|
$mycalc{'innodb_buffer_alloc_pct'} = select_one($lreq)
|
||||||
|
if ( $opt{experimental} );
|
||||||
|
|
||||||
# Binlog Cache
|
# Binlog Cache
|
||||||
if ( $myvar{'log_bin'} ne 'OFF' ) {
|
if ( $myvar{'log_bin'} ne 'OFF' ) {
|
||||||
$mycalc{'pct_binlog_cache'} = percentage(
|
$mycalc{'pct_binlog_cache'} = percentage(
|
||||||
|
@ -3379,22 +3383,25 @@ sub mysql_stats {
|
||||||
. " ($mycalc{'pct_max_physical_memory'}% of installed RAM)";
|
. " ($mycalc{'pct_max_physical_memory'}% of installed RAM)";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
if ( $physical_memory <
|
if ( $physical_memory <
|
||||||
( $mycalc{'max_peak_memory'} + get_other_process_memory() ) )
|
( $mycalc{'max_peak_memory'} + get_other_process_memory() ) )
|
||||||
{
|
{
|
||||||
if ( $opt{nondedicated}) {
|
if ( $opt{nondedicated} ) {
|
||||||
infoprint "No warning with --nondedicated option";
|
infoprint "No warning with --nondedicated option";
|
||||||
infoprint "Overall possible memory usage with other process exceeded memory";
|
infoprint
|
||||||
} else {
|
"Overall possible memory usage with other process exceeded memory";
|
||||||
badprint
|
}
|
||||||
"Overall possible memory usage with other process exceeded memory";
|
else {
|
||||||
push( @generalrec,
|
badprint
|
||||||
"Dedicate this server to your database for highest performance." );
|
"Overall possible memory usage with other process exceeded memory";
|
||||||
}
|
push( @generalrec,
|
||||||
} else {
|
"Dedicate this server to your database for highest performance."
|
||||||
goodprint
|
);
|
||||||
"Overall possible memory usage with other process is compatible with memory available";
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
goodprint
|
||||||
|
"Overall possible memory usage with other process is compatible with memory available";
|
||||||
}
|
}
|
||||||
|
|
||||||
# Slow queries
|
# Slow queries
|
||||||
|
@ -6391,24 +6398,27 @@ sub mysql_innodb {
|
||||||
}
|
}
|
||||||
|
|
||||||
# select round( 100* sum(allocated)/( select VARIABLE_VALUE
|
# select round( 100* sum(allocated)/( select VARIABLE_VALUE
|
||||||
# FROM performance_schema.global_variables
|
# FROM information_schema.global_variables
|
||||||
# where VARIABLE_NAME='innodb_buffer_pool_size' )
|
# where VARIABLE_NAME='innodb_buffer_pool_size' )
|
||||||
# ,2) as "PCT ALLOC/BUFFER POOL"
|
# ,2) as "PCT ALLOC/BUFFER POOL"
|
||||||
#from sys.x$innodb_buffer_stats_by_table;
|
#from sys.x$innodb_buffer_stats_by_table;
|
||||||
|
|
||||||
if ( $opt{experimental} ) {
|
if ( $opt{experimental} ) {
|
||||||
debugprint ('innodb_buffer_alloc_pct: "'.$mycalc{innodb_buffer_alloc_pct}.'"');
|
debugprint( 'innodb_buffer_alloc_pct: "'
|
||||||
if (defined $mycalc{innodb_buffer_alloc_pct} and
|
. $mycalc{innodb_buffer_alloc_pct}
|
||||||
$mycalc{innodb_buffer_alloc_pct} ne '' ) {
|
. '"' );
|
||||||
if ( $mycalc{innodb_buffer_alloc_pct} < 80 ) {
|
if ( defined $mycalc{innodb_buffer_alloc_pct}
|
||||||
badprint "Ratio Buffer Pool allocated / Buffer Pool Size: "
|
and $mycalc{innodb_buffer_alloc_pct} ne '' )
|
||||||
. $mycalc{'innodb_buffer_alloc_pct'} . '%';
|
{
|
||||||
|
if ( $mycalc{innodb_buffer_alloc_pct} < 80 ) {
|
||||||
|
badprint "Ratio Buffer Pool allocated / Buffer Pool Size: "
|
||||||
|
. $mycalc{'innodb_buffer_alloc_pct'} . '%';
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
goodprint "Ratio Buffer Pool allocated / Buffer Pool Size: "
|
||||||
|
. $mycalc{'innodb_buffer_alloc_pct'} . '%';
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else {
|
|
||||||
goodprint "Ratio Buffer Pool allocated / Buffer Pool Size: "
|
|
||||||
. $mycalc{'innodb_buffer_alloc_pct'} . '%';
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
if ( $mycalc{'innodb_log_size_pct'} < 20
|
if ( $mycalc{'innodb_log_size_pct'} < 20
|
||||||
or $mycalc{'innodb_log_size_pct'} > 30 )
|
or $mycalc{'innodb_log_size_pct'} > 30 )
|
||||||
|
@ -6436,7 +6446,7 @@ sub mysql_innodb {
|
||||||
. $myvar{'innodb_log_files_in_group'} . " / "
|
. $myvar{'innodb_log_files_in_group'} . " / "
|
||||||
. hr_bytes( $myvar{'innodb_buffer_pool_size'} )
|
. hr_bytes( $myvar{'innodb_buffer_pool_size'} )
|
||||||
. " should be equal to 25%";
|
. " should be equal to 25%";
|
||||||
push(
|
push(
|
||||||
@adjvars,
|
@adjvars,
|
||||||
"innodb_log_file_size should be (="
|
"innodb_log_file_size should be (="
|
||||||
. hr_bytes_rnd(
|
. hr_bytes_rnd(
|
||||||
|
@ -7229,8 +7239,8 @@ sub headerprint {
|
||||||
. "\t * Major Hayden <major\@mhtx.net>\n"
|
. "\t * Major Hayden <major\@mhtx.net>\n"
|
||||||
. " >> Bug reports, feature requests, and downloads at http://mysqltuner.pl/\n"
|
. " >> Bug reports, feature requests, and downloads at http://mysqltuner.pl/\n"
|
||||||
. " >> Run with '--help' for additional options and output filtering";
|
. " >> Run with '--help' for additional options and output filtering";
|
||||||
debugprint("Debug: ".$opt{debug});
|
debugprint( "Debug: " . $opt{debug} );
|
||||||
debugprint("Experimental: ".$opt{experimental});
|
debugprint( "Experimental: " . $opt{experimental} );
|
||||||
}
|
}
|
||||||
|
|
||||||
sub string2file {
|
sub string2file {
|
||||||
|
|
Loading…
Reference in a new issue