Skip to content

Commit

Permalink
Indenting mysqltuner at 2024-07-15T22:41:49+02:00
Browse files Browse the repository at this point in the history
  • Loading branch information
jmrenouard committed Jul 15, 2024
1 parent def7f81 commit 13d2783
Showing 1 changed file with 63 additions and 53 deletions.
116 changes: 63 additions & 53 deletions mysqltuner.pl
Original file line number Diff line number Diff line change
Expand Up @@ -215,7 +215,7 @@ package main;
# Activate debug variables
#if ( $opt{debug} ne '' ) { $opt{debug} = 2; }
# 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
if ( $opt{feature} ne '' ) { $opt{verbose} = 1; }
Expand Down Expand Up @@ -595,7 +595,8 @@ sub os_setup {
chomp($physical_memory);
chomp($swap_memory);
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'}{'Physical Memory'}{'bytes'} = $physical_memory;
$result{'OS'}{'Physical Memory'}{'pretty'} = hr_bytes($physical_memory);
Expand Down Expand Up @@ -2055,27 +2056,28 @@ sub system_recommendations {
infoprint "User process except mysqld used "
. hr_bytes_rnd($omem) . " RAM.";
if ( ( 0.15 * $physical_memory ) < $omem ) {
if ( $opt{nondedicated}) {
infoprint "No warning with --nondedicated option";
infoprint
if ( $opt{nondedicated} ) {
infoprint "No warning with --nondedicated option";
infoprint
"Other user process except mysqld used more than 15% of total physical memory "
. percentage( $omem, $physical_memory ) . "% ("
. hr_bytes_rnd($omem) . " / "
. hr_bytes_rnd($physical_memory) . ")";
} else {
. percentage( $omem, $physical_memory ) . "% ("
. hr_bytes_rnd($omem) . " / "
. hr_bytes_rnd($physical_memory) . ")";
}
else {

badprint
badprint
"Other user process except mysqld used more than 15% of total physical memory "
. percentage( $omem, $physical_memory ) . "% ("
. hr_bytes_rnd($omem) . " / "
. hr_bytes_rnd($physical_memory) . ")";
push( @generalrec,
. percentage( $omem, $physical_memory ) . "% ("
. hr_bytes_rnd($omem) . " / "
. hr_bytes_rnd($physical_memory) . ")";
push( @generalrec,
"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!"
);
}
);
}
}
else {
infoprint
Expand Down Expand Up @@ -3234,12 +3236,14 @@ sub calculations {
$mystat{'Innodb_buffer_pool_pages_total'}
) if defined $mystat{'Innodb_buffer_pool_pages_total'};

my $lreq= "select ROUND( 100* sum(allocated)/ ".
$myvar{'innodb_buffer_pool_size'} .
',1) FROM sys.x\$innodb_buffer_stats_by_table;';
debugprint("lreq: $lreq");
$mycalc{'innodb_buffer_alloc_pct'} = select_one( $lreq )
if ($opt{experimental});
my $lreq =
"select ROUND( 100* sum(allocated)/ "
. $myvar{'innodb_buffer_pool_size'}
. ',1) FROM sys.x\$innodb_buffer_stats_by_table;';
debugprint("lreq: $lreq");
$mycalc{'innodb_buffer_alloc_pct'} = select_one($lreq)
if ( $opt{experimental} );

# Binlog Cache
if ( $myvar{'log_bin'} ne 'OFF' ) {
$mycalc{'pct_binlog_cache'} = percentage(
Expand Down Expand Up @@ -3379,22 +3383,25 @@ sub mysql_stats {
. " ($mycalc{'pct_max_physical_memory'}% of installed RAM)";
}


if ( $physical_memory <
( $mycalc{'max_peak_memory'} + get_other_process_memory() ) )
( $mycalc{'max_peak_memory'} + get_other_process_memory() ) )
{
if ( $opt{nondedicated}) {
infoprint "No warning with --nondedicated option";
infoprint "Overall possible memory usage with other process exceeded memory";
} else {
badprint
"Overall possible memory usage with other process exceeded memory";
push( @generalrec,
"Dedicate this server to your database for highest performance." );
}
} else {
goodprint
"Overall possible memory usage with other process is compatible with memory available";
if ( $opt{nondedicated} ) {
infoprint "No warning with --nondedicated option";
infoprint
"Overall possible memory usage with other process exceeded memory";
}
else {
badprint
"Overall possible memory usage with other process exceeded memory";
push( @generalrec,
"Dedicate this server to your database for highest performance."
);
}
}
else {
goodprint
"Overall possible memory usage with other process is compatible with memory available";
}

# Slow queries
Expand Down Expand Up @@ -6391,24 +6398,27 @@ sub mysql_innodb {
}

# 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' )
# ,2) as "PCT ALLOC/BUFFER POOL"
#from sys.x$innodb_buffer_stats_by_table;

if ( $opt{experimental} ) {
debugprint ('innodb_buffer_alloc_pct: "'.$mycalc{innodb_buffer_alloc_pct}.'"');
if (defined $mycalc{innodb_buffer_alloc_pct} and
$mycalc{innodb_buffer_alloc_pct} ne '' ) {
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'} . '%';
debugprint( 'innodb_buffer_alloc_pct: "'
. $mycalc{innodb_buffer_alloc_pct}
. '"' );
if ( defined $mycalc{innodb_buffer_alloc_pct}
and $mycalc{innodb_buffer_alloc_pct} ne '' )
{
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'} . '%';
}
}
}
}
if ( $mycalc{'innodb_log_size_pct'} < 20
or $mycalc{'innodb_log_size_pct'} > 30 )
Expand Down Expand Up @@ -6436,7 +6446,7 @@ sub mysql_innodb {
. $myvar{'innodb_log_files_in_group'} . " / "
. hr_bytes( $myvar{'innodb_buffer_pool_size'} )
. " should be equal to 25%";
push(
push(
@adjvars,
"innodb_log_file_size should be (="
. hr_bytes_rnd(
Expand Down Expand Up @@ -7229,8 +7239,8 @@ sub headerprint {
. "\t * Major Hayden <major\@mhtx.net>\n"
. " >> Bug reports, feature requests, and downloads at http://mysqltuner.pl/\n"
. " >> Run with '--help' for additional options and output filtering";
debugprint("Debug: ".$opt{debug});
debugprint("Experimental: ".$opt{experimental});
debugprint( "Debug: " . $opt{debug} );
debugprint( "Experimental: " . $opt{experimental} );
}

sub string2file {
Expand Down

0 comments on commit 13d2783

Please sign in to comment.