Skip to content

Commit 56b7415

Browse files
authored
Merge pull request #788 from jmrenouard/master
MErge back
2 parents 099d38b + aba69e1 commit 56b7415

File tree

9 files changed

+473
-61
lines changed

9 files changed

+473
-61
lines changed

.dockerignore

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
*.md
2+
*.md
3+
build/**
4+
Makefile
5+
.perltidy
6+
*.json
7+
*.png

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,3 +19,4 @@ sql/*.sql
1919
sql/*.csv
2020
cve.csv
2121
default*.cnf
22+
.env

CURRENT_VERSION.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+

Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ RUN apt-get update && apt upgrade -y && apt-get install -yq --no-install-recomme
1616
&& apt-get clean \
1717
&& rm -rf /var/lib/apt/lists/* \
1818
&& mkdir -p /results
19-
19+
RUN apt clean all
2020
WORKDIR /
2121
COPY ./mysqltuner.pl /mysqltuner.pl
2222
COPY ./vulnerabilities.csv /vulnerabilities.txt

Makefile

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,9 @@ help:
2020

2121

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

2627
tidy:
2728
dos2unix ./mysqltuner.pl
@@ -72,7 +73,15 @@ increment_major_version:
7273
git push --tags
7374

7475
docker_build:
75-
docker build .
76+
docker build . -t jmrenouard/mysqltuner:latest -t jmrenouard/mysqltuner:$(VERSION)
77+
78+
docker_slim:
79+
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
80+
81+
docker_push: docker_build
82+
bash build/publishtodockerhub.sh $(VERSION)
83+
84+
7685
push:
7786
git push
7887

USAGE.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# NAME
22

3-
MySQLTuner 2.5.3 - MySQL High Performance Tuning Script
3+
MySQLTuner 2.5.4 - MySQL High Performance Tuning Script
44

55
# IMPORTANT USAGE GUIDELINES
66

build/publishtodockerhub.sh

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
#!/bin/bash
2+
3+
[ -f "./.env" ] && source ./.env
4+
[ -f "../.env" ] && source ../.env
5+
6+
VERSION=$1
7+
8+
docker login -u $DOCKER_USER_LOGIN -p $DOCKER_USER_PASSWORD
9+
docker tag jmrenouard/mysqltuner:latest jmrenouard/mysqltuner:$VERSION
10+
docker push jmrenouard/mysqltuner:latest
11+
docker push jmrenouard/mysqltuner:$VERSION

mysqltuner.pl

Lines changed: 67 additions & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
#!/usr/bin/env perl
2-
# mysqltuner.pl - Version 2.5.3
2+
# mysqltuner.pl - Version 2.5.4
33
# High Performance MySQL Tuning Script
44
# Copyright (C) 2015-2023 Jean-Marie Renouard - [email protected]
55
# Copyright (C) 2006-2023 Major Hayden - [email protected]
@@ -57,7 +57,7 @@ package main;
5757
#use Env;
5858

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

6363
# Set defaults
@@ -215,7 +215,7 @@ package main;
215215
# Activate debug variables
216216
#if ( $opt{debug} ne '' ) { $opt{debug} = 2; }
217217
# Activate experimental calculations and analysis
218-
#if ( $opt{experimental} ne '' ) { $opt{experimental} = 1; }
218+
#if ( $opt{experimental} ne '' ) { $opt{experimental} = 1; }
219219

220220
# check if we need to enable verbose mode
221221
if ( $opt{feature} ne '' ) { $opt{verbose} = 1; }
@@ -595,6 +595,8 @@ sub os_setup {
595595
chomp($physical_memory);
596596
chomp($swap_memory);
597597
chomp($os);
598+
$physical_memory = $opt{forcemem}
599+
if ( defined( $opt{forcemem} ) and $opt{forcemem} gt 0 );
598600
$result{'OS'}{'OS Type'} = $os;
599601
$result{'OS'}{'Physical Memory'}{'bytes'} = $physical_memory;
600602
$result{'OS'}{'Physical Memory'}{'pretty'} = hr_bytes($physical_memory);
@@ -2054,27 +2056,28 @@ sub system_recommendations {
20542056
infoprint "User process except mysqld used "
20552057
. hr_bytes_rnd($omem) . " RAM.";
20562058
if ( ( 0.15 * $physical_memory ) < $omem ) {
2057-
if ( $opt{nondedicated}) {
2058-
infoprint "No warning with --nondedicated option";
2059-
infoprint
2059+
if ( $opt{nondedicated} ) {
2060+
infoprint "No warning with --nondedicated option";
2061+
infoprint
20602062
"Other user process except mysqld used more than 15% of total physical memory "
2061-
. percentage( $omem, $physical_memory ) . "% ("
2062-
. hr_bytes_rnd($omem) . " / "
2063-
. hr_bytes_rnd($physical_memory) . ")";
2064-
} else {
2063+
. percentage( $omem, $physical_memory ) . "% ("
2064+
. hr_bytes_rnd($omem) . " / "
2065+
. hr_bytes_rnd($physical_memory) . ")";
2066+
}
2067+
else {
20652068

2066-
badprint
2069+
badprint
20672070
"Other user process except mysqld used more than 15% of total physical memory "
2068-
. percentage( $omem, $physical_memory ) . "% ("
2069-
. hr_bytes_rnd($omem) . " / "
2070-
. hr_bytes_rnd($physical_memory) . ")";
2071-
push( @generalrec,
2071+
. percentage( $omem, $physical_memory ) . "% ("
2072+
. hr_bytes_rnd($omem) . " / "
2073+
. hr_bytes_rnd($physical_memory) . ")";
2074+
push( @generalrec,
20722075
"Consider stopping or dedicate server for additional process other than mysqld."
2073-
);
2074-
push( @adjvars,
2076+
);
2077+
push( @adjvars,
20752078
"DON'T APPLY SETTINGS BECAUSE THERE ARE TOO MANY PROCESSES RUNNING ON THIS SERVER. OOM KILL CAN OCCUR!"
2076-
);
2077-
}
2079+
);
2080+
}
20782081
}
20792082
else {
20802083
infoprint
@@ -2548,7 +2551,7 @@ sub check_architecture {
25482551
}
25492552
elsif ( `uname` =~ /Darwin/ && `uname -m` =~ /x86_64/ ) {
25502553

2551-
# 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
2554+
# 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
25522555
$arch = 64;
25532556
goodprint "Operating on 64-bit architecture";
25542557
}
@@ -3233,12 +3236,14 @@ sub calculations {
32333236
$mystat{'Innodb_buffer_pool_pages_total'}
32343237
) if defined $mystat{'Innodb_buffer_pool_pages_total'};
32353238

3236-
my $lreq= "select ROUND( 100* sum(allocated)/ ".
3237-
$myvar{'innodb_buffer_pool_size'} .
3238-
',1) FROM sys.x\$innodb_buffer_stats_by_table;';
3239-
debugprint("lreq: $lreq");
3240-
$mycalc{'innodb_buffer_alloc_pct'} = select_one( $lreq )
3241-
if ($opt{experimental});
3239+
my $lreq =
3240+
"select ROUND( 100* sum(allocated)/ "
3241+
. $myvar{'innodb_buffer_pool_size'}
3242+
. ',1) FROM sys.x\$innodb_buffer_stats_by_table;';
3243+
debugprint("lreq: $lreq");
3244+
$mycalc{'innodb_buffer_alloc_pct'} = select_one($lreq)
3245+
if ( $opt{experimental} );
3246+
32423247
# Binlog Cache
32433248
if ( $myvar{'log_bin'} ne 'OFF' ) {
32443249
$mycalc{'pct_binlog_cache'} = percentage(
@@ -3378,22 +3383,25 @@ sub mysql_stats {
33783383
. " ($mycalc{'pct_max_physical_memory'}% of installed RAM)";
33793384
}
33803385

3381-
33823386
if ( $physical_memory <
3383-
( $mycalc{'max_peak_memory'} + get_other_process_memory() ) )
3387+
( $mycalc{'max_peak_memory'} + get_other_process_memory() ) )
33843388
{
3385-
if ( $opt{nondedicated}) {
3386-
infoprint "No warning with --nondedicated option";
3387-
infoprint "Overall possible memory usage with other process exceeded memory";
3388-
} else {
3389-
badprint
3390-
"Overall possible memory usage with other process exceeded memory";
3391-
push( @generalrec,
3392-
"Dedicate this server to your database for highest performance." );
3393-
}
3394-
} else {
3395-
goodprint
3396-
"Overall possible memory usage with other process is compatible with memory available";
3389+
if ( $opt{nondedicated} ) {
3390+
infoprint "No warning with --nondedicated option";
3391+
infoprint
3392+
"Overall possible memory usage with other process exceeded memory";
3393+
}
3394+
else {
3395+
badprint
3396+
"Overall possible memory usage with other process exceeded memory";
3397+
push( @generalrec,
3398+
"Dedicate this server to your database for highest performance."
3399+
);
3400+
}
3401+
}
3402+
else {
3403+
goodprint
3404+
"Overall possible memory usage with other process is compatible with memory available";
33973405
}
33983406

33993407
# Slow queries
@@ -6390,24 +6398,27 @@ sub mysql_innodb {
63906398
}
63916399

63926400
# select round( 100* sum(allocated)/( select VARIABLE_VALUE
6393-
# FROM performance_schema.global_variables
6401+
# FROM information_schema.global_variables
63946402
# where VARIABLE_NAME='innodb_buffer_pool_size' )
63956403
# ,2) as "PCT ALLOC/BUFFER POOL"
63966404
#from sys.x$innodb_buffer_stats_by_table;
63976405

63986406
if ( $opt{experimental} ) {
6399-
debugprint ('innodb_buffer_alloc_pct: "'.$mycalc{innodb_buffer_alloc_pct}.'"');
6400-
if (defined $mycalc{innodb_buffer_alloc_pct} and
6401-
$mycalc{innodb_buffer_alloc_pct} ne '' ) {
6402-
if ( $mycalc{innodb_buffer_alloc_pct} < 80 ) {
6403-
badprint "Ratio Buffer Pool allocated / Buffer Pool Size: "
6404-
. $mycalc{'innodb_buffer_alloc_pct'} . '%';
6405-
}
6406-
else {
6407-
goodprint "Ratio Buffer Pool allocated / Buffer Pool Size: "
6408-
. $mycalc{'innodb_buffer_alloc_pct'} . '%';
6407+
debugprint( 'innodb_buffer_alloc_pct: "'
6408+
. $mycalc{innodb_buffer_alloc_pct}
6409+
. '"' );
6410+
if ( defined $mycalc{innodb_buffer_alloc_pct}
6411+
and $mycalc{innodb_buffer_alloc_pct} ne '' )
6412+
{
6413+
if ( $mycalc{innodb_buffer_alloc_pct} < 80 ) {
6414+
badprint "Ratio Buffer Pool allocated / Buffer Pool Size: "
6415+
. $mycalc{'innodb_buffer_alloc_pct'} . '%';
6416+
}
6417+
else {
6418+
goodprint "Ratio Buffer Pool allocated / Buffer Pool Size: "
6419+
. $mycalc{'innodb_buffer_alloc_pct'} . '%';
6420+
}
64096421
}
6410-
}
64116422
}
64126423
if ( $mycalc{'innodb_log_size_pct'} < 20
64136424
or $mycalc{'innodb_log_size_pct'} > 30 )
@@ -6435,7 +6446,7 @@ sub mysql_innodb {
64356446
. $myvar{'innodb_log_files_in_group'} . " / "
64366447
. hr_bytes( $myvar{'innodb_buffer_pool_size'} )
64376448
. " should be equal to 25%";
6438-
push(
6449+
push(
64396450
@adjvars,
64406451
"innodb_log_file_size should be (="
64416452
. hr_bytes_rnd(
@@ -7228,8 +7239,8 @@ sub headerprint {
72287239
. "\t * Major Hayden <major\@mhtx.net>\n"
72297240
. " >> Bug reports, feature requests, and downloads at http://mysqltuner.pl/\n"
72307241
. " >> Run with '--help' for additional options and output filtering";
7231-
debugprint("Debug: ".$opt{debug});
7232-
debugprint("Experimental: ".$opt{experimental});
7242+
debugprint( "Debug: " . $opt{debug} );
7243+
debugprint( "Experimental: " . $opt{experimental} );
72337244
}
72347245

72357246
sub string2file {
@@ -7431,7 +7442,7 @@ sub which {
74317442
74327443
=head1 NAME
74337444
7434-
MySQLTuner 2.5.3 - MySQL High Performance Tuning Script
7445+
MySQLTuner 2.5.4 - MySQL High Performance Tuning Script
74357446
74367447
=head1 IMPORTANT USAGE GUIDELINES
74377448

0 commit comments

Comments
 (0)