Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MErge back #788

Merged
merged 4 commits into from
Jul 15, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
*.md
*.md
build/**
Makefile
.perltidy
*.json
*.png
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -19,3 +19,4 @@ sql/*.sql
sql/*.csv
cve.csv
default*.cnf
.env
1 change: 1 addition & 0 deletions CURRENT_VERSION.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@

2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ RUN apt-get update && apt upgrade -y && apt-get install -yq --no-install-recomme
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/* \
&& mkdir -p /results

RUN apt clean all
WORKDIR /
COPY ./mysqltuner.pl /mysqltuner.pl
COPY ./vulnerabilities.csv /vulnerabilities.txt
Expand Down
15 changes: 12 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,9 @@ help:


installdep_debian:
apt install -y cpanminus libpod-markdown-perl libwww-mechanize-gzip-perl perltidy dos2unix
cpanm File::Util
sudo apt install -y cpanminus libpod-markdown-perl libwww-mechanize-gzip-perl perltidy dos2unix
sudo cpanm File::Util
curl -sL https://raw.githubusercontent.com/slimtoolkit/slim/master/scripts/install-slim.sh | sudo -E bash -

tidy:
dos2unix ./mysqltuner.pl
Expand Down Expand Up @@ -72,7 +73,15 @@ increment_major_version:
git push --tags

docker_build:
docker build .
docker build . -t jmrenouard/mysqltuner:latest -t jmrenouard/mysqltuner:$(VERSION)

docker_slim:
docker run --rm -it --privileged -v /var/run/docker.sock:/var/run/docker.sock -v $(PWD):/root/app -w /root/app jmrenouard/mysqltuner:latest slim build

docker_push: docker_build
bash build/publishtodockerhub.sh $(VERSION)


push:
git push

Expand Down
2 changes: 1 addition & 1 deletion USAGE.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# NAME

MySQLTuner 2.5.3 - MySQL High Performance Tuning Script
MySQLTuner 2.5.4 - MySQL High Performance Tuning Script

# IMPORTANT USAGE GUIDELINES

Expand Down
11 changes: 11 additions & 0 deletions build/publishtodockerhub.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#!/bin/bash

[ -f "./.env" ] && source ./.env
[ -f "../.env" ] && source ../.env

VERSION=$1

docker login -u $DOCKER_USER_LOGIN -p $DOCKER_USER_PASSWORD
docker tag jmrenouard/mysqltuner:latest jmrenouard/mysqltuner:$VERSION
docker push jmrenouard/mysqltuner:latest
docker push jmrenouard/mysqltuner:$VERSION
123 changes: 67 additions & 56 deletions mysqltuner.pl
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#!/usr/bin/env perl
# mysqltuner.pl - Version 2.5.3
# mysqltuner.pl - Version 2.5.4
# High Performance MySQL Tuning Script
# Copyright (C) 2015-2023 Jean-Marie Renouard - [email protected]
# Copyright (C) 2006-2023 Major Hayden - [email protected]
Expand Down Expand Up @@ -57,7 +57,7 @@ package main;
#use Env;

# Set up a few variables for use in the script
my $tunerversion = "2.5.3";
my $tunerversion = "2.5.4";
my ( @adjvars, @generalrec );

# Set defaults
Expand Down 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,6 +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 );
$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 @@ -2054,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 @@ -2548,7 +2551,7 @@ sub check_architecture {
}
elsif ( `uname` =~ /Darwin/ && `uname -m` =~ /x86_64/ ) {

# Darwin gibas.local 12.5.3 Darwin Kernel Version 12.3.0: Sun Jan 6 22:37:10 PST 2013; root:xnu-2050.22.13~1/RELEASE_X86_64 x86_64
# Darwin gibas.local 12.5.4 Darwin Kernel Version 12.3.0: Sun Jan 6 22:37:10 PST 2013; root:xnu-2050.22.13~1/RELEASE_X86_64 x86_64
$arch = 64;
goodprint "Operating on 64-bit architecture";
}
Expand Down Expand Up @@ -3233,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 @@ -3378,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 @@ -6390,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 @@ -6435,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 @@ -7228,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 Expand Up @@ -7431,7 +7442,7 @@ sub which {

=head1 NAME

MySQLTuner 2.5.3 - MySQL High Performance Tuning Script
MySQLTuner 2.5.4 - MySQL High Performance Tuning Script

=head1 IMPORTANT USAGE GUIDELINES

Expand Down
Loading