Update Vulnerabilities list

Indenting mysqltuner
Update Usage information
This commit is contained in:
Jean-Marie Renouard 2022-06-23 14:31:46 +02:00
parent 4a4629f862
commit ba21312e00

View file

@ -204,10 +204,10 @@ $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{colstat} = 0 if ( $opt{nocolstat} == 1 ); # Don't Print column information
$opt{dbstat} = 0 if ( $opt{nodbstat} == 1 ); # Don't Print database information $opt{dbstat} = 0 if ( $opt{nodbstat} == 1 ); # Don't Print database information
$opt{noprocess} = 0 $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{sysstat} = 0 if ( $opt{nosysstat} == 1 ); # Don't Print sysstat information
$opt{pfstat} = 0 $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 $opt{idxstat} = 0 if ( $opt{noidxstat} == 1 ); # Don't Print index information
# for RPM distributions # for RPM distributions
@ -255,9 +255,9 @@ my @dblist;
# Super structure containing all information # Super structure containing all information
my %result; my %result;
$result{'MySQLTuner'}{'version'} = $tunerversion; $result{'MySQLTuner'}{'version'} = $tunerversion;
$result{'MySQLTuner'}{'datetime'} =`date '+%d-%m-%Y %H:%M:%S'`; $result{'MySQLTuner'}{'datetime'} = `date '+%d-%m-%Y %H:%M:%S'`;
$result{'MySQLTuner'}{'options'} = \%opt; $result{'MySQLTuner'}{'options'} = \%opt;
# Functions that handle the print styles # Functions that handle the print styles
sub prettyprint { sub prettyprint {
@ -594,7 +594,7 @@ sub update_tuner_version {
} }
my $update; my $update;
my $fullpath=""; my $fullpath = "";
my $url = "https://raw.githubusercontent.com/major/MySQLTuner-perl/master/"; my $url = "https://raw.githubusercontent.com/major/MySQLTuner-perl/master/";
my @scripts = my @scripts =
( "mysqltuner.pl", "basic_passwords.txt", "vulnerabilities.csv" ); ( "mysqltuner.pl", "basic_passwords.txt", "vulnerabilities.csv" );
@ -607,12 +607,12 @@ sub update_tuner_version {
if ( $httpcli =~ /curl$/ ) { if ( $httpcli =~ /curl$/ ) {
debugprint "$httpcli is available."; debugprint "$httpcli is available.";
$fullpath=dirname(__FILE__)."/".$script; $fullpath = dirname(__FILE__) . "/" . $script;
debugprint "FullPath: $fullpath"; debugprint "FullPath: $fullpath";
debugprint debugprint
"$httpcli --connect-timeout 3 '$url$script' 2>$devnull > $fullpath"; "$httpcli --connect-timeout 3 '$url$script' 2>$devnull > $fullpath";
$update = $update =
`$httpcli --connect-timeout 3 '$url$script' 2>$devnull > $fullpath`; `$httpcli --connect-timeout 3 '$url$script' 2>$devnull > $fullpath`;
chomp($update); chomp($update);
debugprint "$script updated: $update"; debugprint "$script updated: $update";
@ -747,7 +747,7 @@ sub mysql_setup {
$remotestring = " -S $opt{socket} -P $opt{port}"; $remotestring = " -S $opt{socket} -P $opt{port}";
} }
if ( $opt{protocol} ne '' ){ if ( $opt{protocol} ne '' ) {
$remotestring = " --protocol=$opt{protocol}"; $remotestring = " --protocol=$opt{protocol}";
} }
@ -1359,7 +1359,8 @@ sub log_file_recommendations {
subheaderprint "Log file Recommendations"; subheaderprint "Log file Recommendations";
if ( "$myvar{'log_error'}" eq "stderr" ) { if ( "$myvar{'log_error'}" eq "stderr" ) {
badprint "log_error is set to $myvar{'log_error'}, but this script can't read stderr"; badprint
"log_error is set to $myvar{'log_error'}, but this script can't read stderr";
return; return;
} }
elsif ( $myvar{'log_error'} =~ /^(docker|podman|kubectl):(.*)/ ) { elsif ( $myvar{'log_error'} =~ /^(docker|podman|kubectl):(.*)/ ) {
@ -1423,7 +1424,7 @@ sub log_file_recommendations {
$numLi++; $numLi++;
debugprint "$numLi: $logLi" debugprint "$numLi: $logLi"
if $logLi =~ /warning|error/i and $logLi !~ /Logging to/; if $logLi =~ /warning|error/i and $logLi !~ /Logging to/;
$nbErrLog++ if $logLi =~ /error/i and $logLi !~ /Logging to/; $nbErrLog++ if $logLi =~ /error/i and $logLi !~ /Logging to/;
$nbWarnLog++ if $logLi =~ /warning/i; $nbWarnLog++ if $logLi =~ /warning/i;
push @lastShutdowns, $logLi push @lastShutdowns, $logLi
if $logLi =~ /Shutdown complete/ and $logLi !~ /Innodb/i; if $logLi =~ /Shutdown complete/ and $logLi !~ /Innodb/i;
@ -1945,21 +1946,25 @@ sub security_recommendations {
debugprint "Password column = $PASS_COLUMN_NAME"; debugprint "Password column = $PASS_COLUMN_NAME";
# IS THERE A ROLE COLUMN # IS THERE A ROLE COLUMN
my $is_role_column = select_one "select count(*) from information_schema.columns where TABLE_NAME='user' AND TABLE_SCHEMA='mysql' and COLUMN_NAME='IS_ROLE'"; my $is_role_column = select_one
"select count(*) from information_schema.columns where TABLE_NAME='user' AND TABLE_SCHEMA='mysql' and COLUMN_NAME='IS_ROLE'";
my $extra_user_condition="";
$extra_user_condition="IS_ROLE = 'N' AND" if $is_role_column > 0; my $extra_user_condition = "";
$extra_user_condition = "IS_ROLE = 'N' AND" if $is_role_column > 0;
my @mysqlstatlist; my @mysqlstatlist;
if ($is_role_column > 0) { if ( $is_role_column > 0 ) {
@mysqlstatlist= select_array "SELECT CONCAT(QUOTE(user), '\@', QUOTE(host)) FROM mysql.user WHERE IS_ROLE='Y'"; @mysqlstatlist = select_array
"SELECT CONCAT(QUOTE(user), '\@', QUOTE(host)) FROM mysql.user WHERE IS_ROLE='Y'";
foreach my $line ( sort @mysqlstatlist ) { foreach my $line ( sort @mysqlstatlist ) {
chomp($line); chomp($line);
infoprint "User $line is User Role"; infoprint "User $line is User Role";
} }
} else {
debugprint "No Role user detected";
goodprint "No Role user detected";
} }
else {
debugprint "No Role user detected";
goodprint "No Role user detected";
}
# Looking for Anonymous users # Looking for Anonymous users
@mysqlstatlist = select_array @mysqlstatlist = select_array
"SELECT CONCAT(QUOTE(user), '\@', QUOTE(host)) FROM mysql.user WHERE $extra_user_condition (TRIM(USER) = '' OR USER IS NULL)"; "SELECT CONCAT(QUOTE(user), '\@', QUOTE(host)) FROM mysql.user WHERE $extra_user_condition (TRIM(USER) = '' OR USER IS NULL)";
@ -2135,14 +2140,22 @@ sub get_replication_status {
infoprint "Semi synchronous replication Master: " infoprint "Semi synchronous replication Master: "
. ( . (
( defined( $myvar{'rpl_semi_sync_master_enabled'} ) or defined( $myvar{'rpl_semi_sync_source_enabled'} ) ) (
? ( $myvar{'rpl_semi_sync_master_enabled'} // $myvar{'rpl_semi_sync_source_enabled'} ) defined( $myvar{'rpl_semi_sync_master_enabled'} )
or defined( $myvar{'rpl_semi_sync_source_enabled'} )
)
? ( $myvar{'rpl_semi_sync_master_enabled'}
// $myvar{'rpl_semi_sync_source_enabled'} )
: 'Not Activated' : 'Not Activated'
); );
infoprint "Semi synchronous replication Slave: " infoprint "Semi synchronous replication Slave: "
. ( . (
( defined( $myvar{'rpl_semi_sync_slave_enabled'} ) or defined( $myvar{'rpl_semi_sync_replica_enabled'} ) ) (
? ( $myvar{'rpl_semi_sync_slave_enabled'} // $myvar{'rpl_semi_sync_replica_enabled'} ) defined( $myvar{'rpl_semi_sync_slave_enabled'} )
or defined( $myvar{'rpl_semi_sync_replica_enabled'} )
)
? ( $myvar{'rpl_semi_sync_slave_enabled'}
// $myvar{'rpl_semi_sync_replica_enabled'} )
: 'Not Activated' : 'Not Activated'
); );
if ( scalar( keys %myrepl ) == 0 and scalar( keys %myslaves ) == 0 ) { if ( scalar( keys %myrepl ) == 0 and scalar( keys %myslaves ) == 0 ) {
@ -2156,13 +2169,15 @@ sub get_replication_status {
} }
$result{'Replication'}{'status'} = \%myrepl; $result{'Replication'}{'status'} = \%myrepl;
my ($io_running) = $myrepl{'Slave_IO_Running'} // $myrepl{'Replica_IO_Running'}; my ($io_running) = $myrepl{'Slave_IO_Running'}
// $myrepl{'Replica_IO_Running'};
debugprint "IO RUNNING: $io_running "; debugprint "IO RUNNING: $io_running ";
my ($sql_running) = $myrepl{'Slave_SQL_Running'} // $myrepl{'Replica_SQL_Running'}; my ($sql_running) = $myrepl{'Slave_SQL_Running'}
// $myrepl{'Replica_SQL_Running'};
debugprint "SQL RUNNING: $sql_running "; debugprint "SQL RUNNING: $sql_running ";
my ($seconds_behind_master) = $myrepl{'Seconds_Behind_Master'}
my ($seconds_behind_master) = $myrepl{'Seconds_Behind_Master'} // $myrepl{'Seconds_Behind_Source'} ; // $myrepl{'Seconds_Behind_Source'};
$seconds_behind_master = 1000000 unless defined($seconds_behind_master); $seconds_behind_master = 1000000 unless defined($seconds_behind_master);
debugprint "SECONDS : $seconds_behind_master "; debugprint "SECONDS : $seconds_behind_master ";
@ -2173,7 +2188,7 @@ sub get_replication_status {
"This replication slave is not running but seems to be configured."; "This replication slave is not running but seems to be configured.";
} }
if ( defined($io_running) if ( defined($io_running)
&& $io_running =~ /yes/i && $io_running =~ /yes/i
&& $sql_running =~ /yes/i ) && $sql_running =~ /yes/i )
{ {
if ( $myvar{'read_only'} eq 'OFF' ) { if ( $myvar{'read_only'} eq 'OFF' ) {
@ -2209,19 +2224,21 @@ sub validate_mysql_version {
or mysql_version_eq( 10, 5 ) or mysql_version_eq( 10, 5 )
or mysql_version_eq( 10, 6 ) or mysql_version_eq( 10, 6 )
or mysql_version_eq( 10, 7 ) or mysql_version_eq( 10, 7 )
or mysql_version_eq( 10, 8 ) or mysql_version_eq( 10, 8 ) )
)
{ {
goodprint "Currently running supported MySQL version " goodprint "Currently running supported MySQL version "
. $myvar{'version'} . ""; . $myvar{'version'} . "";
return; return;
} else { }
else {
badprint "Your MySQL version " badprint "Your MySQL version "
. $myvar{'version'} . $myvar{'version'}
. " is EOL software! Upgrade soon!"; . " is EOL software! Upgrade soon!";
push ( @generalrec, "You are using n unsupported version for production environments"); push( @generalrec,
push ( @generalrec, "Upgrade as soon as possible to a supported version !"); "You are using n unsupported version for production environments" );
push( @generalrec,
"Upgrade as soon as possible to a supported version !" );
} }
} }
@ -3188,15 +3205,18 @@ sub mysql_stats {
infoprint infoprint
"Skipped name resolution test due to missing skip_name_resolve in system variables."; "Skipped name resolution test due to missing skip_name_resolve in system variables.";
} }
#Cpanel and Skip name resolve #Cpanel and Skip name resolve
elsif ( -r "/usr/local/cpanel/cpanel" ){ elsif ( -r "/usr/local/cpanel/cpanel" ) {
if ( $result{'Variables'}{'skip_name_resolve'} ne 'OFF') { if ( $result{'Variables'}{'skip_name_resolve'} ne 'OFF' ) {
infoprint "CPanel and Flex system skip-name-resolve should be on"; infoprint "CPanel and Flex system skip-name-resolve should be on";
} }
if ( $result{'Variables'}{'skip_name_resolve'} eq 'OFF') { if ( $result{'Variables'}{'skip_name_resolve'} eq 'OFF' ) {
badprint "CPanel and Flex system skip-name-resolve should be on"; badprint "CPanel and Flex system skip-name-resolve should be on";
push (@generalrec, "name resolution is enabled due to cPanel doesn't support this disabled."); push( @generalrec,
push (@adjvars, "skip-name-resolve=0"); "name resolution is enabled due to cPanel doesn't support this disabled."
);
push( @adjvars, "skip-name-resolve=0" );
} }
} }
elsif ( $result{'Variables'}{'skip_name_resolve'} eq 'OFF' ) { elsif ( $result{'Variables'}{'skip_name_resolve'} eq 'OFF' ) {
@ -3205,7 +3225,7 @@ sub mysql_stats {
push( @generalrec, push( @generalrec,
"Configure your accounts with ip or subnets only, then update your configuration with skip-name-resolve=1" "Configure your accounts with ip or subnets only, then update your configuration with skip-name-resolve=1"
); );
push (@adjvars, "skip-name-resolve=1"); push( @adjvars, "skip-name-resolve=1" );
} }
# Query cache # Query cache
@ -3620,15 +3640,15 @@ sub mysql_myisam {
subheaderprint "MyISAM Metrics"; subheaderprint "MyISAM Metrics";
if ( mysql_version_ge(8) and mysql_version_le(10) ) { if ( mysql_version_ge(8) and mysql_version_le(10) ) {
infoprint "MyISAM Metrics are disabled on last MySQL versions."; infoprint "MyISAM Metrics are disabled on last MySQL versions.";
if ( $myvar{'key_buffer_size'} > 0) { if ( $myvar{'key_buffer_size'} > 0 ) {
push( @adjvars, "key_buffer_size=0" ); push( @adjvars, "key_buffer_size=0" );
push( @generalrec, "Buffer Key MyISAM set to 0, no MyISAM table detected" ); push( @generalrec,
"Buffer Key MyISAM set to 0, no MyISAM table detected" );
} }
return; return;
} }
my $nb_myisam_tables=select_one( my $nb_myisam_tables = select_one(
"SELECT COUNT(*) FROM information_schema.TABLES WHERE ENGINE='MyISAM'" "SELECT COUNT(*) FROM information_schema.TABLES WHERE ENGINE='MyISAM'");
);
if ( $nb_myisam_tables == 0 ) { if ( $nb_myisam_tables == 0 ) {
infoprint "No MyISAM table(s) detected ...."; infoprint "No MyISAM table(s) detected ....";
return; return;
@ -3858,13 +3878,12 @@ sub mysqsl_pfs {
# Performance Schema # Performance Schema
$myvar{'performance_schema'} = 'OFF' $myvar{'performance_schema'} = 'OFF'
unless defined( $myvar{'performance_schema'} ); unless defined( $myvar{'performance_schema'} );
if ($myvar{'performance_schema'} eq 'OFF') { if ( $myvar{'performance_schema'} eq 'OFF' ) {
badprint "Performance_schema should be activated."; badprint "Performance_schema should be activated.";
push( @adjvars, "performance_schema=ON" ); push( @adjvars, "performance_schema=ON" );
push( @generalrec, push( @generalrec,
"Performance schema should be activated for better diagnostics" "Performance schema should be activated for better diagnostics" );
); }
}
if ( $myvar{'performance_schema'} eq 'ON' ) { if ( $myvar{'performance_schema'} eq 'ON' ) {
infoprint "Performance_schema is activated."; infoprint "Performance_schema is activated.";
debugprint "Performance schema is " . $myvar{'performance_schema'}; debugprint "Performance schema is " . $myvar{'performance_schema'};
@ -3888,9 +3907,9 @@ sub mysqsl_pfs {
infoprint "Sys schema Version: " infoprint "Sys schema Version: "
. select_one("select sys_version from sys.version"); . select_one("select sys_version from sys.version");
# Store all sys schema # Store all sys schema
# for my $pfs_view(select_array('use sys;show tables;')){ # for my $pfs_view(select_array('use sys;show tables;')){
#infoprint "$pfs_view" #infoprint "$pfs_view"
# @$result{'sys'}{$pfs_view}{'headers'}=[]; # @$result{'sys'}{$pfs_view}{'headers'}=[];
# for my $h (select_array("select column_name FROM INFORMATION_SCHEMA.COLUMNS c # for my $h (select_array("select column_name FROM INFORMATION_SCHEMA.COLUMNS c
# WHERE c.table_name = '$pfs_view' ORDER BY c.ORDINAL_POSITION")) { # WHERE c.table_name = '$pfs_view' ORDER BY c.ORDINAL_POSITION")) {
@ -3902,7 +3921,7 @@ sub mysqsl_pfs {
# push $result{'sys'}{$pfs_view}{'values'}, $lQuery; # push $result{'sys'}{$pfs_view}{'values'}, $lQuery;
# } # }
# } # }
# Top user per connection # Top user per connection
subheaderprint "Performance schema: Top 5 user per connection"; subheaderprint "Performance schema: Top 5 user per connection";
my $nbL = 1; my $nbL = 1;
for my $lQuery ( for my $lQuery (
@ -6669,7 +6688,7 @@ sub mysql_triggers() {
# Take the two recommendation arrays and display them at the end of the output # Take the two recommendation arrays and display them at the end of the output
sub make_recommendations { sub make_recommendations {
$result{'Recommendations'} = \@generalrec; $result{'Recommendations'} = \@generalrec;
$result{'AdjustVariables'} = \@adjvars; $result{'AdjustVariables'} = \@adjvars;
subheaderprint "Recommendations"; subheaderprint "Recommendations";
if ( @generalrec > 0 ) { if ( @generalrec > 0 ) {
@ -6695,8 +6714,7 @@ sub close_outputfile {
} }
sub headerprint { sub headerprint {
prettyprint prettyprint " >> MySQLTuner $tunerversion\n"
" >> MySQLTuner $tunerversion\n"
. "\t * Jean-Marie Renouard <jmrenouard\@gmail.com>\n" . "\t * Jean-Marie Renouard <jmrenouard\@gmail.com>\n"
. "\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"
@ -6847,25 +6865,25 @@ system_recommendations; # avoid to many service on the same host
log_file_recommendations; # check log file content log_file_recommendations; # check log file content
check_storage_engines; # Show enabled storage engines check_storage_engines; # Show enabled storage engines
check_metadata_perf; # Show parameter impacting performance during analysis check_metadata_perf; # Show parameter impacting performance during analysis
mysql_databases; # Show informations about databases mysql_databases; # Show informations about databases
mysql_tables; # Show informations about table column mysql_tables; # Show informations about table column
mysql_indexes; # Show informations about indexes mysql_indexes; # Show informations about indexes
mysql_views; # Show informations about views mysql_views; # Show informations about views
mysql_triggers; # Show informations about triggers mysql_triggers; # Show informations about triggers
mysql_routines; # Show informations about routines mysql_routines; # Show informations about routines
security_recommendations; # Display some security recommendations security_recommendations; # Display some security recommendations
cve_recommendations; # Display related CVE cve_recommendations; # Display related CVE
calculations; # Calculate everything we need calculations; # Calculate everything we need
mysql_stats; # Print the server stats mysql_stats; # Print the server stats
mysqsl_pfs; # Print Performance schema info mysqsl_pfs; # Print Performance schema info
mariadb_threadpool; # Print MariaDB ThreadPool stats mariadb_threadpool; # Print MariaDB ThreadPool stats
mysql_myisam; # Print MyISAM stats mysql_myisam; # Print MyISAM stats
mysql_innodb; # Print InnoDB stats mysql_innodb; # Print InnoDB stats
mariadb_aria; # Print MariaDB Aria stats mariadb_aria; # Print MariaDB Aria stats
mariadb_tokudb; # Print MariaDB Tokudb stats mariadb_tokudb; # Print MariaDB Tokudb stats
mariadb_xtradb; # Print MariaDB XtraDB stats mariadb_xtradb; # Print MariaDB XtraDB stats
#mariadb_rockdb; # Print MariaDB RockDB stats #mariadb_rockdb; # Print MariaDB RockDB stats
#mariadb_spider; # Print MariaDB Spider stats #mariadb_spider; # Print MariaDB Spider stats