Update Vulnerabilities list

Indenting mysqltuner
Update Usage information
This commit is contained in:
Jean-Marie Renouard 2022-12-29 05:13:02 +01:00
parent 57b4f69680
commit 390977624e
2 changed files with 102 additions and 290 deletions

View file

@ -917,17 +917,21 @@ sub mysql_setup {
return 1;
}
}
elsif ( $opt{'defaults-extra-file'} ne '' and -r "$opt{'defaults-extra-file'}" ) {
elsif ( $opt{'defaults-extra-file'} ne ''
and -r "$opt{'defaults-extra-file'}" )
{
# defaults-extra-file
debugprint "defaults extra file detected: $opt{'defaults-extra-file'}";
my $mysqlclidefaults = `$mysqlcmd --print-defaults`;
debugprint "MySQL Client Extra Default File: $opt{'defaults-extra-file'}";
debugprint
"MySQL Client Extra Default File: $opt{'defaults-extra-file'}";
$mysqllogin = "--defaults-extra-file=" . $opt{'defaults-extra-file'};
my $loginstatus = `$mysqladmincmd $mysqllogin ping 2>&1`;
if ( $loginstatus =~ /mysqld is alive/ ) {
goodprint "Logged in using credentials from extra defaults file account.";
goodprint
"Logged in using credentials from extra defaults file account.";
return 1;
}
}
@ -1190,7 +1194,7 @@ sub get_all_vars {
$dummyselect = select_one "SELECT VERSION()";
if ( not defined($dummyselect) or $dummyselect eq "" ) {
badprint
"You probably do not have enough privileges to run MySQLTuner ...";
"You probably do not have enough privileges to run MySQLTuner ...";
exit(256);
}
$dummyselect =~ s/(.*?)\-.*/$1/;
@ -2254,7 +2258,8 @@ sub validate_mysql_version {
. $myvar{'version'}
. " is EOL software. Upgrade soon!";
push( @generalrec,
"You are using an unsupported version for production environments" );
"You are using an unsupported version for production environments"
);
push( @generalrec,
"Upgrade as soon as possible to a supported version !" );
@ -2554,7 +2559,7 @@ sub check_storage_engines {
{
badprint "MyISAM is enabled but isn't being used";
push( @generalrec,
"Add skip-isam to MySQL configuration to disable MyISAM (MySQL > 4.1.0)"
"Add skip-isam to MySQL configuration to disable MyISAM (MySQL > 4.1.0)"
);
}
@ -2562,7 +2567,7 @@ sub check_storage_engines {
if ( $fragtables > 0 ) {
badprint "Total fragmented tables: $fragtables";
push @generalrec,
'Run ALTER TABLE ... FORCE or OPTIMIZE TABLE to defragment tables for better performance';
'Run ALTER TABLE ... FORCE or OPTIMIZE TABLE to defragment tables for better performance';
my $total_free = 0;
foreach my $table_line ( @{ $result{'Tables'}{'Fragmented tables'} } ) {
my ( $table_schema, $table_name, $engine, $data_free ) =
@ -2571,8 +2576,10 @@ sub check_storage_engines {
$total_free += $data_free;
my $generalrec;
if ( $engine eq 'InnoDB' ) {
$generalrec = " ALTER TABLE `$table_schema`.`$table_name` FORCE;";
} else {
$generalrec =
" ALTER TABLE `$table_schema`.`$table_name` FORCE;";
}
else {
$generalrec = " OPTIMIZE TABLE `$table_schema`.`$table_name`;";
}
$generalrec .= " -- can free $data_free MiB";
@ -2636,8 +2643,7 @@ my %mycalc;
sub calculations {
if ( $mystat{'Questions'} < 1 ) {
badprint
"Your server has not answered any queries: cannot continue...";
badprint "Your server has not answered any queries: cannot continue...";
exit 2;
}
@ -3066,7 +3072,8 @@ sub mysql_stats {
. " global + "
. hr_bytes( $mycalc{'per_thread_buffers'} )
. " per thread ($myvar{'max_connections'} max threads)";
infoprint "Performance_schema Max memory usage: " . hr_bytes_rnd( get_pf_memory() );
infoprint "Performance_schema Max memory usage: "
. hr_bytes_rnd( get_pf_memory() );
$result{'Performance_schema'}{'memory'} = get_pf_memory();
$result{'Performance_schema'}{'pretty_memory'} =
hr_bytes_rnd( get_pf_memory() );
@ -3680,8 +3687,8 @@ sub mysql_myisam {
if ( $mycalc{'pct_key_buffer_used'} < 90 ) {
badprint "Key buffer used: $mycalc{'pct_key_buffer_used'}% ("
. hr_bytes( $myvar{'key_buffer_size'} -
$mystat{'Key_blocks_unused'} *
$myvar{'key_cache_block_size'} )
$mystat{'Key_blocks_unused'} * $myvar{'key_cache_block_size'}
)
. " used / "
. hr_bytes( $myvar{'key_buffer_size'} )
. " cache)";
@ -3699,8 +3706,8 @@ sub mysql_myisam {
else {
goodprint "Key buffer used: $mycalc{'pct_key_buffer_used'}% ("
. hr_bytes( $myvar{'key_buffer_size'} -
$mystat{'Key_blocks_unused'} *
$myvar{'key_cache_block_size'} )
$mystat{'Key_blocks_unused'} * $myvar{'key_cache_block_size'}
)
. " used / "
. hr_bytes( $myvar{'key_buffer_size'} )
. " cache)";
@ -3908,16 +3915,17 @@ sub mysqsl_pfs {
if ( $myvar{'performance_schema'} eq 'ON' ) {
infoprint "Performance_schema is activated.";
debugprint "Performance schema is " . $myvar{'performance_schema'};
infoprint "Memory used by Performance_schema: " . hr_bytes( get_pf_memory() );
infoprint "Memory used by Performance_schema: "
. hr_bytes( get_pf_memory() );
}
unless ( grep /^sys$/, select_array("SHOW DATABASES") ) {
infoprint "Sys schema is not installed.";
push( @generalrec,
"Consider installing Sys schema from https://github.com/mysql/mysql-sys for MySQL"
"Consider installing Sys schema from https://github.com/mysql/mysql-sys for MySQL"
) unless ( mysql_version_le( 5, 6 ) );
push( @generalrec,
"Consider installing Sys schema from https://github.com/FromDual/mariadb-sys for MariaDB"
"Consider installing Sys schema from https://github.com/FromDual/mariadb-sys for MariaDB"
) unless ( mysql_version_ge( 10, 0 ) );
return;
@ -5620,19 +5628,19 @@ having sum(if(c.column_key in ('PRI','UNI'), 1,0)) = 0"
or get_wsrep_option('wsrep_slave_threads') < ( (cpu_cores) * 2 ) )
{
badprint
"wsrep_slave_threads is not equal to 2, 3 or 4 times the number of CPU(s)";
"wsrep_slave_threads is not equal to 2, 3 or 4 times the number of CPU(s)";
push @adjvars, "wsrep_slave_threads = " . ( (cpu_cores) * 4 );
}
else {
goodprint
"wsrep_slave_threads is equal to 2, 3 or 4 times the number of CPU(s)";
"wsrep_slave_threads is equal to 2, 3 or 4 times the number of CPU(s)";
}
if ( get_wsrep_option('wsrep_slave_threads') > 1 ) {
infoprint
"wsrep parallel slave can cause frequent inconsistency crash.";
push @adjvars,
"Set wsrep_slave_threads to 1 in case of HA_ERR_FOUND_DUPP_KEY crash on slave";
"Set wsrep_slave_threads to 1 in case of HA_ERR_FOUND_DUPP_KEY crash on slave";
# check options for parallel slave
if ( get_wsrep_option('wsrep_slave_FK_checks') eq "OFF" ) {
@ -5675,7 +5683,7 @@ having sum(if(c.column_key in ('PRI','UNI'), 1,0)) = 0"
}
else {
goodprint
"Flow control fraction seems to be OK (wsrep_flow_control_paused <= 0.02)";
"Flow control fraction seems to be OK (wsrep_flow_control_paused <= 0.02)";
}
if ( scalar(@primaryKeysNbTables) > 0 ) {
@ -5737,14 +5745,14 @@ having sum(if(c.column_key in ('PRI','UNI'), 1,0)) = 0"
}
else {
badprint
"There are $nbNodesSize nodes in wsrep_cluster_size. Prefer 3 or 5 nodes architecture.";
"There are $nbNodesSize nodes in wsrep_cluster_size. Prefer 3 or 5 nodes architecture.";
push @generalrec, "Prefer 3 or 5 nodes architecture.";
}
# wsrep_cluster_address doesn't include garbd nodes
if ( $nbNodes > $nbNodesSize ) {
badprint
"All cluster nodes are not detected. wsrep_cluster_size less than node count in wsrep_cluster_address";
"All cluster nodes are not detected. wsrep_cluster_size less than node count in wsrep_cluster_address";
}
else {
goodprint "All cluster nodes detected.";
@ -5782,14 +5790,15 @@ having sum(if(c.column_key in ('PRI','UNI'), 1,0)) = 0"
}
else {
badprint "Galera Notify command is not defined.";
push( @adjvars, "set up parameter wsrep_notify_cmd to be notified" );
push( @adjvars,
"set up parameter wsrep_notify_cmd to be notified" );
}
if ( trim( $myvar{'wsrep_sst_method'} ) !~ "^xtrabackup.*"
and trim( $myvar{'wsrep_sst_method'} ) !~ "^mariabackup" )
{
badprint "Galera SST method is not xtrabackup based.";
push( @adjvars,
"set up parameter wsrep_sst_method to xtrabackup based parameter"
"set up parameter wsrep_sst_method to xtrabackup based parameter"
);
}
else {
@ -5891,10 +5900,10 @@ sub mysql_innodb {
$defengine = $myvar{'default_storage_engine'}
if defined( $myvar{'default_storage_engine'} );
badprint
"InnoDB Storage engine is disabled. $defengine is the default storage engine"
"InnoDB Storage engine is disabled. $defengine is the default storage engine"
if $defengine eq 'InnoDB';
infoprint
"InnoDB Storage engine is disabled. $defengine is the default storage engine"
"InnoDB Storage engine is disabled. $defengine is the default storage engine"
if $defengine ne 'InnoDB';
}
return;
@ -6557,7 +6566,7 @@ sub mysql_indexes {
subheaderprint "Indexes Metrics";
unless ( mysql_version_ge( 5, 5 ) ) {
infoprint
"Skip Index metrics from information schema are missing in this version";
"Skip Index metrics from information schema are missing in this version";
return;
}
@ -6684,7 +6693,7 @@ sub mysql_views() {
subheaderprint "Views Metrics";
unless ( mysql_version_ge( 5, 5 ) ) {
infoprint
"Skip Index metrics from information schema are missing in this version";
"Skip Index metrics from information schema are missing in this version";
return;
}
}
@ -6693,7 +6702,7 @@ sub mysql_routines() {
subheaderprint "Routines Metrics";
unless ( mysql_version_ge( 5, 5 ) ) {
infoprint
"Skip Index metrics from information schema are missing in this version";
"Skip Index metrics from information schema are missing in this version";
return;
}
}
@ -6702,7 +6711,7 @@ sub mysql_triggers() {
subheaderprint "Triggers Metrics";
unless ( mysql_version_ge( 5, 5 ) ) {
infoprint
"Skip Index metrics from information schema are missing in this version";
"Skip Index metrics from information schema are missing in this version";
return;
}
}

File diff suppressed because one or more lines are too long