Update Vulnerabilities list

Indenting mysqltuner
Update Usage information
This commit is contained in:
Jean-Marie Renouard 2023-03-11 07:48:00 +01:00
parent 881479eca8
commit b29eb05b2b
2 changed files with 76 additions and 55 deletions

View file

@ -1,6 +1,6 @@
# NAME # NAME
MySQLTuner 2.0.10 - MySQL High Performance Tuning Script MySQLTuner 2.1.1 - MySQL High Performance Tuning Script
# IMPORTANT USAGE GUIDELINES # IMPORTANT USAGE GUIDELINES
@ -23,7 +23,7 @@ You must provide the remote server's total memory when connecting to other serve
--mysqladmin <path> Path to a custom mysqladmin executable --mysqladmin <path> Path to a custom mysqladmin executable
--mysqlcmd <path> Path to a custom mysql executable --mysqlcmd <path> Path to a custom mysql executable
--defaults-file <path> Path to a custom .my.cnf --defaults-file <path> Path to a custom .my.cnf
--defaults-extra-file <path> Path to a extra custom config file --defaults-extra-file <path> Path to an extra custom config file
--server-log <path> Path to explicit log file (error_log) --server-log <path> Path to explicit log file (error_log)
# PERFORMANCE AND REPORTING OPTIONS # PERFORMANCE AND REPORTING OPTIONS
@ -42,6 +42,7 @@ You must provide the remote server's total memory when connecting to other serve
--outputfile <path> Path to a output txt file --outputfile <path> Path to a output txt file
--reportfile <path> Path to a report txt file --reportfile <path> Path to a report txt file
--template <path> Path to a template file --template <path> Path to a template file
--dumpdir <path> Path to a directory where to dump information files
# OUTPUT OPTIONS # OUTPUT OPTIONS
@ -85,6 +86,7 @@ You can find documentation for this module with the perldoc command.
# AUTHORS # AUTHORS
Major Hayden - major@mhtx.net Major Hayden - major@mhtx.net
Jean-Marie Renouard - jmrenouard@gmail.com
# CONTRIBUTORS # CONTRIBUTORS
@ -122,6 +124,7 @@ Major Hayden - major@mhtx.net
- Jean-Marie Renouard - Jean-Marie Renouard
- Stephan GroBberndt - Stephan GroBberndt
- Christian Loos - Christian Loos
- Long Radix
# SUPPORT # SUPPORT
@ -129,7 +132,7 @@ Bug reports, feature requests, and downloads at http://mysqltuner.pl/
Bug tracker can be found at https://github.com/major/MySQLTuner-perl/issues Bug tracker can be found at https://github.com/major/MySQLTuner-perl/issues
Maintained by Major Hayden (major\\@mhtx.net) - Licensed under GPL Maintained by Jean-Marie Renouard (jmrenouard\\@gmail.com) - Licensed under GPL
# SOURCE CODE # SOURCE CODE
@ -139,7 +142,8 @@ Maintained by Major Hayden (major\\@mhtx.net) - Licensed under GPL
# COPYRIGHT AND LICENSE # COPYRIGHT AND LICENSE
Copyright (C) 2006-2022 Major Hayden - major@mhtx.net Copyright (C) 2006-2023 Major Hayden - major@mhtx.net
\# Copyright (C) 2015-2023 Jean-Marie Renouard - jmrenouard@gmail.com
For the latest updates, please visit http://mysqltuner.pl/ For the latest updates, please visit http://mysqltuner.pl/

View file

@ -115,33 +115,33 @@ my %opt = (
# Gather the options from the command line # Gather the options from the command line
GetOptions( GetOptions(
\%opt, 'nobad', \%opt, 'nobad',
'nogood', 'noinfo', 'nogood', 'noinfo',
'debug', 'nocolor', 'debug', 'nocolor',
'forcemem=i', 'forceswap=i', 'forcemem=i', 'forceswap=i',
'host=s', 'socket=s', 'host=s', 'socket=s',
'port=i', 'user=s', 'port=i', 'user=s',
'pass=s', 'skipsize', 'pass=s', 'skipsize',
'checkversion', 'mysqladmin=s', 'checkversion', 'mysqladmin=s',
'mysqlcmd=s', 'help', 'mysqlcmd=s', 'help',
'buffers', 'skippassword', 'buffers', 'skippassword',
'passwordfile=s', 'outputfile=s', 'passwordfile=s', 'outputfile=s',
'silent', 'noask', 'silent', 'noask',
'json', 'prettyjson', 'json', 'prettyjson',
'template=s', 'reportfile=s', 'template=s', 'reportfile=s',
'cvefile=s', 'bannedports=s', 'cvefile=s', 'bannedports=s',
'updateversion', 'maxportallowed=s', 'updateversion', 'maxportallowed=s',
'verbose', 'password=s', 'verbose', 'password=s',
'passenv=s', 'userenv=s', 'passenv=s', 'userenv=s',
'defaults-file=s', 'ssl-ca=s', 'defaults-file=s', 'ssl-ca=s',
'color', 'noprocess', 'color', 'noprocess',
'dbstat', 'nodbstat', 'dbstat', 'nodbstat',
'tbstat', 'notbstat', 'tbstat', 'notbstat',
'colstat', 'nocolstat', 'colstat', 'nocolstat',
'sysstat', 'nosysstat', 'sysstat', 'nosysstat',
'pfstat', 'nopfstat', 'pfstat', 'nopfstat',
'idxstat', 'noidxstat', 'idxstat', 'noidxstat',
'server-log=s', 'protocol=s', 'server-log=s', 'protocol=s',
'defaults-extra-file=s', 'dumpdir=s', 'defaults-extra-file=s', 'dumpdir=s',
) )
or pod2usage( or pod2usage(
@ -187,12 +187,13 @@ if ( exists $opt{passenv} && exists $ENV{ $opt{passenv} } ) {
} }
$opt{pass} = $opt{password} if ( $opt{pass} eq 0 and $opt{password} ne 0 ); $opt{pass} = $opt{password} if ( $opt{pass} eq 0 and $opt{password} ne 0 );
if ($opt{dumpdir} ne '') { if ( $opt{dumpdir} ne '' ) {
$opt{dumpdir} = abs_path( $opt{dumpdir} ); $opt{dumpdir} = abs_path( $opt{dumpdir} );
if ( ! -d $opt{dumpdir} ) { if ( !-d $opt{dumpdir} ) {
mkdir $opt{dumpdir} or die "Cannot create directory $opt{dumpdir}: $!"; mkdir $opt{dumpdir} or die "Cannot create directory $opt{dumpdir}: $!";
} }
} }
# for RPM distributions # for RPM distributions
$basic_password_files = "/usr/share/mysqltuner/basic_passwords.txt" $basic_password_files = "/usr/share/mysqltuner/basic_passwords.txt"
unless -f "$basic_password_files"; unless -f "$basic_password_files";
@ -797,9 +798,12 @@ sub mysql_setup {
} }
} }
# Did we already get a username with or without password on the command line? # Did we already get a username with or without password on the command line?
if ( $opt{user} ne 0 ) { if ( $opt{user} ne 0 ) {
$mysqllogin = "-u $opt{user} " . (($opt{pass} ne 0) ? "-p'$opt{pass}' " : " ") . $remotestring; $mysqllogin =
"-u $opt{user} "
. ( ( $opt{pass} ne 0 ) ? "-p'$opt{pass}' " : " " )
. $remotestring;
my $loginstatus = `$mysqladmincmd ping $mysqllogin 2>&1`; my $loginstatus = `$mysqladmincmd ping $mysqllogin 2>&1`;
if ( $loginstatus =~ /mysqld is alive/ ) { if ( $loginstatus =~ /mysqld is alive/ ) {
goodprint "Logged in using credentials passed on the command line"; goodprint "Logged in using credentials passed on the command line";
@ -988,6 +992,7 @@ sub mysql_setup {
$mysqllogin .= $remotestring; $mysqllogin .= $remotestring;
my $loginstatus = `$mysqladmincmd ping $mysqllogin 2>&1`; my $loginstatus = `$mysqladmincmd ping $mysqllogin 2>&1`;
if ( $loginstatus =~ /mysqld is alive/ ) { if ( $loginstatus =~ /mysqld is alive/ ) {
#print STDERR ""; #print STDERR "";
if ( !length($password) ) { if ( !length($password) ) {
@ -1031,21 +1036,23 @@ sub select_array {
chomp(@result); chomp(@result);
return @result; return @result;
} }
# MySQL Request Array # MySQL Request Array
sub select_csv_file { sub select_csv_file {
my $tfile= shift; my $tfile = shift;
my $req = shift; my $req = shift;
debugprint "PERFORM: $req CSV into $tfile"; debugprint "PERFORM: $req CSV into $tfile";
my @result =select_array($req); my @result = select_array($req);
open( my $fh, '>', $tfile ) or die "Could not open file '$tfile' $!"; open( my $fh, '>', $tfile ) or die "Could not open file '$tfile' $!";
for my $l (@result) { for my $l (@result) {
$l=~s/\t/","/g; $l =~ s/\t/","/g;
$l=~s/^/"/; $l =~ s/^/"/;
$l=~s/$/"/; $l =~ s/$/"/;
print $fh $l; print $fh $l;
} }
close $fh; close $fh;
} }
sub human_size { sub human_size {
my ( $size, $n ) = ( shift, 0 ); my ( $size, $n ) = ( shift, 0 );
++$n and $size /= 1024 until $size < 1024; ++$n and $size /= 1024 until $size < 1024;
@ -3921,9 +3928,9 @@ sub mysqsl_pfs {
unless ( grep /^sys$/, select_array("SHOW DATABASES") ) { unless ( grep /^sys$/, select_array("SHOW DATABASES") ) {
infoprint "Sys schema is not installed."; infoprint "Sys schema is not installed.";
push( @generalrec, push( @generalrec,
mysql_version_ge( 10, 0 ) ? mysql_version_ge( 10, 0 )
"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"
"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 ) ); ) unless ( mysql_version_le( 5, 6 ) );
return; return;
@ -3934,14 +3941,18 @@ 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 in dumpdir if defined # Store all sys schema in dumpdir if defined
if ( defined $opt{dumpdir} and -d "$opt{dumpdir}" ) { if ( defined $opt{dumpdir} and -d "$opt{dumpdir}" ) {
for my $pfs_view(select_array('use sys;show tables;')){ for my $pfs_view ( select_array('use sys;show tables;') ) {
infoprint "Dumping $pfs_view into $opt{dumpdir}"; infoprint "Dumping $pfs_view into $opt{dumpdir}";
select_csv_file("$opt{dumpdir}/pfs_$pfs_view.csv", "select * from sys.$pfs_view"); select_csv_file(
"$opt{dumpdir}/pfs_$pfs_view.csv",
"select * from sys.$pfs_view"
);
}
} }
}
# 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 (
@ -6463,11 +6474,17 @@ sub mysql_tables {
infoprint "Disabling colstat parameter"; infoprint "Disabling colstat parameter";
} }
# Store all information schema in dumpdir if defined # Store all information schema in dumpdir if defined
if ( defined $opt{dumpdir} and -d "$opt{dumpdir}" ) { if ( defined $opt{dumpdir} and -d "$opt{dumpdir}" ) {
for my $info_s_table(select_array('use information_schema;show tables;')){ for my $info_s_table (
infoprint "Dumping $info_s_table into $opt{dumpdir}"; select_array('use information_schema;show tables;') )
select_csv_file("$opt{dumpdir}/ifs_${info_s_table}.csv", "select * from information_schema.$info_s_table"); {
infoprint "Dumping $info_s_table into $opt{dumpdir}";
select_csv_file(
"$opt{dumpdir}/ifs_${info_s_table}.csv",
"select * from information_schema.$info_s_table"
);
} }
} }
foreach ( select_user_dbs() ) { foreach ( select_user_dbs() ) {