Merge branch 'master' of https://github.com/major/MySQLTuner-perl
This commit is contained in:
commit
e4a2534349
4 changed files with 74 additions and 36 deletions
14
CODE_OF_CONDUCT.md
Normal file
14
CODE_OF_CONDUCT.md
Normal file
|
@ -0,0 +1,14 @@
|
||||||
|
# Contributor Code of Conduct
|
||||||
|
|
||||||
|
As contributors and maintainers of this project, we pledge to respect all people who contribute through reporting issues, posting feature requests, updating documentation, submitting pull requests or patches, and other activities.
|
||||||
|
|
||||||
|
We are committed to making participation in this project a harassment-free experience for everyone, regardless of level of experience, gender, gender identity and expression, sexual orientation, disability, personal appearance, body size, race, age, or religion.
|
||||||
|
|
||||||
|
Examples of unacceptable behavior by participants include the use of sexual language or imagery, derogatory comments or personal attacks, trolling, public or private harassment, insults, or other unprofessional conduct.
|
||||||
|
|
||||||
|
Project maintainers have the right and responsibility to remove, edit, or reject comments, commits, code, wiki edits, issues, and other contributions that are not aligned to this Code of Conduct. Project maintainers who do not follow the Code of Conduct may be removed from the project team.
|
||||||
|
|
||||||
|
Instances of abusive, harassing, or otherwise unacceptable behavior may be reported by opening an issue or contacting one or more of the project maintainers.
|
||||||
|
|
||||||
|
This Code of Conduct is adapted from the [Contributor Covenant](http:contributor-covenant.org), version 1.0.0, available at [http://contributor-covenant.org/version/1/0/0/](http://contributor-covenant.org/version/1/0/0/)
|
||||||
|
|
3
USAGE.md
3
USAGE.md
|
@ -1,6 +1,6 @@
|
||||||
# NAME
|
# NAME
|
||||||
|
|
||||||
MySQLTuner 1.6.8 - MySQL High Performance Tuning Script
|
MySQLTuner 1.6.10 - MySQL High Performance Tuning Script
|
||||||
|
|
||||||
# IMPORTANT USAGE GUIDELINES
|
# IMPORTANT USAGE GUIDELINES
|
||||||
|
|
||||||
|
@ -39,6 +39,7 @@ You must provide the remote server's total memory when connecting to other serve
|
||||||
--debug Print debug information
|
--debug Print debug information
|
||||||
--dbstat Print database information
|
--dbstat Print database information
|
||||||
--idxstat Print index information
|
--idxstat Print index information
|
||||||
|
--sysstat Print system information
|
||||||
--bannedports Ports banned separated by comma(,)
|
--bannedports Ports banned separated by comma(,)
|
||||||
--maxportallowed Number of ports opened allowed on this hosts
|
--maxportallowed Number of ports opened allowed on this hosts
|
||||||
--cvefile CVE File for vulnerability checks
|
--cvefile CVE File for vulnerability checks
|
||||||
|
|
|
@ -46,6 +46,6 @@ rm -rf $RPM_BUILD_ROOT
|
||||||
%{_mandir}/man1/*
|
%{_mandir}/man1/*
|
||||||
|
|
||||||
%changelog
|
%changelog
|
||||||
* Thu Jan 5 2015 Jean-Marie RENOUARD <jmrenouard@gmail.com> %VERSION%-1
|
* Thu Apr 14 2016 Jean-Marie RENOUARD <jmrenouard@gmail.com> %VERSION%-1
|
||||||
- Initial RPM release
|
- Initial RPM release
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
#!/usr/bin/env perl
|
#!/usr/bin/env perl
|
||||||
# mysqltuner.pl - Version 1.6.9
|
# mysqltuner.pl - Version 1.6.10
|
||||||
# High Performance MySQL Tuning Script
|
# High Performance MySQL Tuning Script
|
||||||
# Copyright (C) 2006-2016 Major Hayden - major@mhtx.net
|
# Copyright (C) 2006-2016 Major Hayden - major@mhtx.net
|
||||||
#
|
#
|
||||||
|
@ -51,7 +51,7 @@ use Data::Dumper;
|
||||||
$Data::Dumper::Pair = " : ";
|
$Data::Dumper::Pair = " : ";
|
||||||
|
|
||||||
# Set up a few variables for use in the script
|
# Set up a few variables for use in the script
|
||||||
my $tunerversion = "1.6.9";
|
my $tunerversion = "1.6.10";
|
||||||
my ( @adjvars, @generalrec );
|
my ( @adjvars, @generalrec );
|
||||||
|
|
||||||
# Set defaults
|
# Set defaults
|
||||||
|
@ -157,7 +157,7 @@ sub usage {
|
||||||
. " --debug Print debug information\n"
|
. " --debug Print debug information\n"
|
||||||
. " --dbstat Print database information\n"
|
. " --dbstat Print database information\n"
|
||||||
. " --idxstat Print index information\n"
|
. " --idxstat Print index information\n"
|
||||||
. "--sysstat Print system information\n"
|
. " --sysstat Print system information\n"
|
||||||
. " --bannedports Ports banned separated by comma(,)\n"
|
. " --bannedports Ports banned separated by comma(,)\n"
|
||||||
. " --maxportallowed Number of ports opened allowed on this hosts\n"
|
. " --maxportallowed Number of ports opened allowed on this hosts\n"
|
||||||
. " --cvefile CVE File for vulnerability checks\n"
|
. " --cvefile CVE File for vulnerability checks\n"
|
||||||
|
@ -933,31 +933,40 @@ sub get_tuning_info {
|
||||||
# Populates all of the variable and status hashes
|
# Populates all of the variable and status hashes
|
||||||
my ( %mystat, %myvar, $dummyselect, %myrepl, %myslaves );
|
my ( %mystat, %myvar, $dummyselect, %myrepl, %myslaves );
|
||||||
|
|
||||||
sub get_all_vars {
|
sub arr2hash {
|
||||||
|
my $href=shift;
|
||||||
|
my $harr=shift;
|
||||||
|
my $sep=shift;
|
||||||
|
$sep='\s' unless defined($sep);
|
||||||
|
foreach my $line (@$harr) {
|
||||||
|
$line =~ /([a-zA-Z_]*)\s*$sep\s*(.*)/;
|
||||||
|
$$href{$1} = $2;
|
||||||
|
debugprint "V: $1 = $2";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
sub get_all_vars {
|
||||||
# We need to initiate at least one query so that our data is useable
|
# We need to initiate at least one query so that our data is useable
|
||||||
$dummyselect = select_one "SELECT VERSION()";
|
$dummyselect = select_one "SELECT VERSION()";
|
||||||
debugprint "VERSION: " . $dummyselect . "";
|
debugprint "VERSION: " . $dummyselect . "";
|
||||||
$result{'MySQL Client'}{'Version'} = $dummyselect;
|
$result{'MySQL Client'}{'Version'} = $dummyselect;
|
||||||
my @mysqlvarlist = select_array "SHOW /*!50000 GLOBAL */ VARIABLES";
|
|
||||||
foreach my $line (@mysqlvarlist) {
|
my @mysqlvarlist = select_array ("SHOW GLOBAL VARIABLES");
|
||||||
$line =~ /([a-zA-Z_]*)\s*(.*)/;
|
push (@mysqlvarlist, select_array ("SHOW VARIABLES"));
|
||||||
$myvar{$1} = $2;
|
arr2hash(\%myvar, \@mysqlvarlist);
|
||||||
$result{'Variables'}{$1} = $2;
|
$result{'Variables'}=%myvar;
|
||||||
debugprint "V: $1 = $2";
|
|
||||||
}
|
my @mysqlstatlist = select_array ("SHOW GLOBAL STATUS");
|
||||||
my @mysqlstatlist = select_array "SHOW /*!50000 GLOBAL */ STATUS";
|
push (@mysqlstatlist, select_array ("SHOW STATUS"));
|
||||||
foreach my $line (@mysqlstatlist) {
|
arr2hash(\%mystat, \@mysqlstatlist);
|
||||||
$line =~ /([a-zA-Z_]*)\s*(.*)/;
|
$result{'Status'}=%mystat;
|
||||||
$mystat{$1} = $2;
|
|
||||||
$result{'Status'}{$1} = $2;
|
|
||||||
debugprint "S: $1 = $2";
|
|
||||||
}
|
|
||||||
$myvar{'have_galera'} = "NO";
|
$myvar{'have_galera'} = "NO";
|
||||||
if ( defined($myvar{'wsrep_provider_options'}) && $myvar{'wsrep_provider_options'} ne "") {
|
if ( defined($myvar{'wsrep_provider_options'}) && $myvar{'wsrep_provider_options'} ne "") {
|
||||||
$myvar{'have_galera'} = "YES";
|
$myvar{'have_galera'} = "YES";
|
||||||
debugprint "Galera options: ". $myvar{'wsrep_provider_options'};
|
debugprint "Galera options: ". $myvar{'wsrep_provider_options'};
|
||||||
}
|
}
|
||||||
|
|
||||||
# Workaround for MySQL bug #59393 wrt. ignore-builtin-innodb
|
# Workaround for MySQL bug #59393 wrt. ignore-builtin-innodb
|
||||||
if ( ( $myvar{'ignore_builtin_innodb'} || "" ) eq "ON" ) {
|
if ( ( $myvar{'ignore_builtin_innodb'} || "" ) eq "ON" ) {
|
||||||
$myvar{'have_innodb'} = "NO";
|
$myvar{'have_innodb'} = "NO";
|
||||||
|
@ -990,16 +999,9 @@ sub get_all_vars {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
debugprint Dumper(@mysqlenginelist);
|
debugprint Dumper(@mysqlenginelist);
|
||||||
my @mysqlslave = select_array "SHOW SLAVE STATUS\\G";
|
my @mysqlslave = select_array("SHOW SLAVE STATUS\\G");
|
||||||
|
arr2hash(\%myrepl, \@mysqlslave, ':');
|
||||||
foreach my $line (@mysqlslave) {
|
$result{'Replication'}{'Status'}=%myrepl;
|
||||||
if ( $line =~ /\s*(.*):\s*(.*)/ ) {
|
|
||||||
debugprint "$1 => $2";
|
|
||||||
$myrepl{"$1"} = $2;
|
|
||||||
$result{'Replication'}{'Status'}{$1} = $2;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
my @mysqlslaves = select_array "SHOW SLAVE HOSTS";
|
my @mysqlslaves = select_array "SHOW SLAVE HOSTS";
|
||||||
my @lineitems = ();
|
my @lineitems = ();
|
||||||
foreach my $line (@mysqlslaves) {
|
foreach my $line (@mysqlslaves) {
|
||||||
|
@ -1107,6 +1109,15 @@ sub get_other_process_memory {
|
||||||
}
|
}
|
||||||
|
|
||||||
sub get_os_release {
|
sub get_os_release {
|
||||||
|
if( -f "/etc/lsb-release") {
|
||||||
|
my @info_release = get_file_contents "/etc/lsb-release";
|
||||||
|
remove_cr @info_release;
|
||||||
|
my $os_relase = $info_release[3];
|
||||||
|
$os_relase =~ s/.*="//;
|
||||||
|
$os_relase =~ s/"$//;
|
||||||
|
return $os_relase;
|
||||||
|
}
|
||||||
|
|
||||||
if( -f "/etc/system-release") {
|
if( -f "/etc/system-release") {
|
||||||
my @info_release = get_file_contents "/etc/system-release";
|
my @info_release = get_file_contents "/etc/system-release";
|
||||||
remove_cr @info_release;
|
remove_cr @info_release;
|
||||||
|
@ -1129,9 +1140,7 @@ sub get_os_release {
|
||||||
$os_relase =~ s/\s+\\n.*//;
|
$os_relase =~ s/\s+\\n.*//;
|
||||||
return $os_relase;
|
return $os_relase;
|
||||||
}
|
}
|
||||||
|
|
||||||
return "Unknown OS release";
|
return "Unknown OS release";
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
sub get_fs_info() {
|
sub get_fs_info() {
|
||||||
|
@ -1169,6 +1178,20 @@ sub get_fs_info() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
sub merge_hash
|
||||||
|
{
|
||||||
|
my $h1=shift;
|
||||||
|
my $h2=shift;
|
||||||
|
my %result={};
|
||||||
|
foreach my $substanceref ( $h1, $h2 ) {
|
||||||
|
while ( my ($k, $v) = each %$substanceref) {
|
||||||
|
next if (exists $result{$k});
|
||||||
|
$result{$k} = $v;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return \%result;
|
||||||
|
}
|
||||||
|
|
||||||
sub is_virtual_machine() {
|
sub is_virtual_machine() {
|
||||||
my $isVm = `grep -Ec '^flags.*\ hypervisor\ ' /proc/cpuinfo`;
|
my $isVm = `grep -Ec '^flags.*\ hypervisor\ ' /proc/cpuinfo`;
|
||||||
return ( $isVm == 0 ? 0 : 1 );
|
return ( $isVm == 0 ? 0 : 1 );
|
||||||
|
@ -3318,8 +3341,8 @@ sub mysql_innodb {
|
||||||
&& $mycalc{'pct_write_efficiency'} < 90 )
|
&& $mycalc{'pct_write_efficiency'} < 90 )
|
||||||
{
|
{
|
||||||
badprint "InnoDB Write Log efficiency: "
|
badprint "InnoDB Write Log efficiency: "
|
||||||
. $mycalc{'pct_write_efficiency'} . "% ("
|
. abs($mycalc{'pct_write_efficiency'}) . "% ("
|
||||||
. ( $mystat{'Innodb_log_write_requests'} -
|
. abs( $mystat{'Innodb_log_write_requests'} -
|
||||||
$mystat{'Innodb_log_writes'} )
|
$mystat{'Innodb_log_writes'} )
|
||||||
. " hits/ "
|
. " hits/ "
|
||||||
. $mystat{'Innodb_log_write_requests'}
|
. $mystat{'Innodb_log_write_requests'}
|
||||||
|
@ -3822,7 +3845,7 @@ __END__
|
||||||
|
|
||||||
=head1 NAME
|
=head1 NAME
|
||||||
|
|
||||||
MySQLTuner 1.6.8 - MySQL High Performance Tuning Script
|
MySQLTuner 1.6.10 - MySQL High Performance Tuning Script
|
||||||
|
|
||||||
=head1 IMPORTANT USAGE GUIDELINES
|
=head1 IMPORTANT USAGE GUIDELINES
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue