@@ -300,10 +300,9 @@ sub infoprinthcmd {
300
300
infoprintcmd " $_ [1]" ;
301
301
}
302
302
303
- # Calculates the number of phyiscal cores considering HyperThreading
303
+ # Calculates the number of phyiscal cores considering HyperThreading
304
304
sub cpu_cores {
305
- my $cntCPU =
306
- ` awk -F: '/^core id/ && !P[\$ 2] { CORES++; P[\$ 2]=1 }; /^physical id/ && !N[\$ 2] { CPUs++; N[\$ 2]=1 }; END { print CPUs*CORES }' /proc/cpuinfo` ;
305
+ my $cntCPU = ` awk -F: '/^core id/ && !P[\$ 2] { CORES++; P[\$ 2]=1 }; /^physical id/ && !N[\$ 2] { CPUs++; N[\$ 2]=1 }; END { print CPUs*CORES }' /proc/cpuinfo` ;
307
306
return ( $cntCPU == 0 ? ` nproc` : $cntCPU );
308
307
}
309
308
@@ -538,8 +537,7 @@ sub validate_tuner_version {
538
537
}
539
538
540
539
my $update ;
541
- my $url =
542
- " https://raw.githubusercontent.com/major/MySQLTuner-perl/master/mysqltuner.pl" ;
540
+ my $url = " https://raw.githubusercontent.com/major/MySQLTuner-perl/master/mysqltuner.pl" ;
543
541
my $httpcli = get_http_cli();
544
542
if ( $httpcli =~ / curl$ / ) {
545
543
debugprint " $httpcli is available." ;
@@ -614,9 +612,9 @@ sub update_tuner_version {
614
612
debugprint " $httpcli is available." ;
615
613
616
614
debugprint
617
- " $httpcli -qe timestamping=off -t 1 -T 3 -O $script '$url$script '" ;
615
+ " $httpcli -qe timestamping=off -t 1 -T 3 -O $script '$url$script '" ;
618
616
$update =
619
- ` $httpcli -qe timestamping=off -t 1 -T 3 -O $script '$url$script '` ;
617
+ ` $httpcli -qe timestamping=off -t 1 -T 3 -O $script '$url$script '` ;
620
618
chomp ($update );
621
619
622
620
if ( -s $script eq 0 ) {
@@ -723,7 +721,7 @@ sub mysql_setup {
723
721
if ( $opt {socket } ne 0 ) {
724
722
$remotestring = " -S $opt {socket} -P $opt {port}" ;
725
723
}
726
-
724
+
727
725
# Are we being asked to connect to a remote server?
728
726
if ( $opt {host } ne 0 ) {
729
727
chomp ( $opt {host } );
@@ -741,9 +739,8 @@ sub mysql_setup {
741
739
if ( ( $opt {host } ne " 127.0.0.1" ) && ( $opt {host } ne " localhost" ) ) {
742
740
$doremote = 1;
743
741
}
744
- }
745
- else {
746
- $opt {host } = ' 127.0.0.1' ;
742
+ } else {
743
+ $opt {host }=' 127.0.0.1' ;
747
744
}
748
745
749
746
# Did we already get a username without password on the command line?
@@ -872,7 +869,6 @@ sub mysql_setup {
872
869
}
873
870
}
874
871
else {
875
-
876
872
# It's not Plesk or debian, we should try a login
877
873
debugprint " $mysqladmincmd $remotestring ping 2>&1" ;
878
874
my $loginstatus = ` $mysqladmincmd $remotestring ping 2>&1` ;
@@ -1471,8 +1467,7 @@ sub get_kernel_info {
1471
1467
badprint
1472
1468
" Swappiness is > 10, please consider having a value lower than 10" ;
1473
1469
push @generalrec , " setup swappiness lower or equals to 10" ;
1474
- push @adjvars ,
1475
- ' vm.swappiness <= 10 (echo 10 > /proc/sys/vm/swappiness)' ;
1470
+ push @adjvars , ' vm.swappiness <= 10 (echo 10 > /proc/sys/vm/swappiness)' ;
1476
1471
}
1477
1472
else {
1478
1473
infoprint " Swappiness is < 10." ;
@@ -1827,7 +1822,7 @@ sub get_replication_status {
1827
1822
" This replication slave is not running but seems to be configured." ;
1828
1823
}
1829
1824
if ( defined ($io_running )
1830
- && $io_running =~ / yes/i
1825
+ && $io_running =~ / yes/i
1831
1826
&& $sql_running =~ / yes/i )
1832
1827
{
1833
1828
if ( $myvar {' read_only' } eq ' OFF' ) {
@@ -2093,7 +2088,7 @@ sub check_storage_engines {
2093
2088
debugprint " Data dump " . Dumper(@$tbl );
2094
2089
my ( $engine , $size , $datafree ) = @$tbl ;
2095
2090
next if $engine eq ' NULL' ;
2096
- $size = 0 if $size eq ' NULL' ;
2091
+ $size = 0 if $size eq ' NULL' ;
2097
2092
$datafree = 0 if $datafree eq ' NULL' ;
2098
2093
if ( defined $enginestats {$engine } ) {
2099
2094
$enginestats {$engine } += $size ;
@@ -2330,7 +2325,7 @@ sub calculations {
2330
2325
$myvar {' key_cache_block_size' }
2331
2326
) / $myvar {' key_buffer_size' }
2332
2327
)
2333
- ) * 100
2328
+ ) * 100
2334
2329
);
2335
2330
}
2336
2331
else {
@@ -2371,9 +2366,8 @@ sub calculations {
2371
2366
}
2372
2367
2373
2368
if ( $mystat {' Key_write_requests' } > 0 ) {
2374
- $mycalc {' pct_wkeys_from_mem' } = sprintf ( " %.1f" ,
2375
- ( ( $mystat {' Key_writes' } / $mystat {' Key_write_requests' } ) * 100 )
2376
- );
2369
+ $mycalc {' pct_wkeys_from_mem' } = sprintf (
2370
+ " %.1f" ,( ($mystat {' Key_writes' } / $mystat {' Key_write_requests' } ) * 100 ) );
2377
2371
}
2378
2372
else {
2379
2373
$mycalc {' pct_wkeys_from_mem' } = 0;
@@ -2417,14 +2411,14 @@ sub calculations {
2417
2411
(
2418
2412
$mystat {' Qcache_hits' } /
2419
2413
( $mystat {' Com_select' } + $mystat {' Qcache_hits' } )
2420
- ) * 100
2414
+ ) * 100
2421
2415
);
2422
2416
if ( $myvar {' query_cache_size' } ) {
2423
2417
$mycalc {' pct_query_cache_used' } = sprintf (
2424
2418
" %.1f" ,
2425
2419
100 - (
2426
2420
$mystat {' Qcache_free_memory' } / $myvar {' query_cache_size' }
2427
- ) * 100
2421
+ ) * 100
2428
2422
);
2429
2423
}
2430
2424
if ( $mystat {' Qcache_lowmem_prunes' } == 0 ) {
@@ -2649,7 +2643,7 @@ sub mysql_stats {
2649
2643
2650
2644
if ( defined $myvar {' query_cache_type' } ) {
2651
2645
infoprint " Query Cache Buffers" ;
2652
- infoprint " +-- Query Cache: "
2646
+ infoprint " +-- Query Cache: "
2653
2647
. $myvar {' query_cache_type' } . " - "
2654
2648
. (
2655
2649
$myvar {' query_cache_type' } eq 0 |
@@ -3152,7 +3146,6 @@ sub mysql_myisam {
3152
3146
}
3153
3147
}
3154
3148
else {
3155
-
3156
3149
# No queries have run that would use keys
3157
3150
debugprint " Key buffer used: $mycalc {'pct_key_buffer_used'}% ("
3158
3151
. hr_num(
@@ -3212,7 +3205,6 @@ sub mysql_myisam {
3212
3205
}
3213
3206
}
3214
3207
else {
3215
-
3216
3208
# No queries have run that would use keys
3217
3209
debugprint " Key buffer size / total MyISAM indexes: "
3218
3210
. hr_bytes( $myvar {' key_buffer_size' } ) . " /"
@@ -3237,7 +3229,6 @@ sub mysql_myisam {
3237
3229
}
3238
3230
}
3239
3231
else {
3240
-
3241
3232
# No queries have run that would use keys
3242
3233
debugprint
3243
3234
" Write Key buffer hit rate: $mycalc {'pct_wkeys_from_mem'}% ("
@@ -5048,11 +5039,11 @@ sub mariadb_galera {
5048
5039
having sum(if(c.column_key in ('PRI','UNI'), 1,0)) = 0"
5049
5040
);
5050
5041
5051
- if ( get_wsrep_option(' wsrep_slave_threads' ) > cpu_cores *4
5052
- or get_wsrep_option(' wsrep_slave_threads' ) < cpu_cores *3 )
5042
+ if ( get_wsrep_option(' wsrep_slave_threads' ) > cpu_cores * 4
5043
+ or get_wsrep_option(' wsrep_slave_threads' ) < cpu_cores * 3 )
5053
5044
{
5054
5045
badprint
5055
- " wsrep_slave_threads is not equal to 2, 3 or 4 times number of CPU(s)" ;
5046
+ " wsrep_slave_threads is not equal to 2, 3 or 4 times number of CPU(s)" ;
5056
5047
push @adjvars , " wsrep_slave_threads= Nb of Core CPU * 4" ;
5057
5048
}
5058
5049
else {
@@ -5065,55 +5056,43 @@ sub mariadb_galera {
5065
5056
{
5066
5057
badprint " gcs.limit should be equal to 5 * wsrep_slave_threads" ;
5067
5058
push @adjvars , " gcs.limit= wsrep_slave_threads * 5" ;
5068
- }
5069
- else {
5059
+ } else {
5070
5060
goodprint " gcs.limit should be equal to 5 * wsrep_slave_threads" ;
5071
5061
}
5072
5062
5073
- if ( get_wsrep_option(' wsrep_slave_threads' ) > 1 ) {
5074
- infoprint
5075
- " wsrep parallel slave can cause frequent inconsistency crash." ;
5076
- push @adjvars ,
5077
- " Set wsrep_slave_threads to 1 in case of HA_ERR_FOUND_DUPP_KEY crash on slave" ;
5078
-
5063
+ if (get_wsrep_option(' wsrep_slave_threads' ) > 1) {
5064
+ infoprint " wsrep parallel slave can cause frequent inconsistency crash." ;
5065
+ push @adjvars , " Set wsrep_slave_threads to 1 in case of HA_ERR_FOUND_DUPP_KEY crash on slave" ;
5079
5066
# check options for parallel slave
5080
- if ( get_wsrep_option(' wsrep_slave_FK_checks' ) eq " OFF" ) {
5067
+ if (get_wsrep_option(' wsrep_slave_FK_checks' ) eq " OFF" ) {
5081
5068
badprint " wsrep_slave_FK_checks is off with parallel slave" ;
5082
- push @adjvars ,
5083
- " wsrep_slave_FK_checks should be ON when using parallel slave" ;
5069
+ push @adjvars , " wsrep_slave_FK_checks should be ON when using parallel slave" ;
5084
5070
}
5085
-
5086
5071
# wsrep_slave_UK_checks seems useless in MySQL source code
5087
- if ( $myvar {' innodb_autoinc_lock_mode' } != 2 ) {
5088
- badprint
5089
- " innodb_autoinc_lock_mode is incorrect with parallel slave" ;
5090
- push @adjvars ,
5091
- " innodb_autoinc_lock_mode should be 2 when using parallel slave" ;
5072
+ if ($myvar {' innodb_autoinc_lock_mode' } != 2) {
5073
+ badprint " innodb_autoinc_lock_mode is incorrect with parallel slave" ;
5074
+ push @adjvars , " innodb_autoinc_lock_mode should be 2 when using parallel slave" ;
5092
5075
}
5093
5076
}
5094
-
5095
- if ( get_wsrep_option(' gcs.fc_limit' ) != $myvar {' wsrep_slave_threads' } * 5 )
5096
- {
5077
+
5078
+ if (get_wsrep_option(' gcs.fc_limit' ) != $myvar {' wsrep_slave_threads' } * 5 ) {
5097
5079
badprint " gcs.fc_limit should be equal to 5 * wsrep_slave_threads" ;
5098
5080
push @adjvars , " gcs.fc_limit= wsrep_slave_threads * 5" ;
5099
- }
5100
- else {
5081
+ } else {
5101
5082
goodprint " gcs.fc_limit is equal to 5 * wsrep_slave_threads" ;
5102
5083
}
5103
-
5104
- if ( get_wsrep_option(' gcs.fc_factor' ) != 0.8 ) {
5084
+
5085
+ if (get_wsrep_option(' gcs.fc_factor' ) != 0.8 ) {
5105
5086
badprint " gcs.fc_factor should be equal to 0.8" ;
5106
5087
push @adjvars , " gcs.fc_factor=0.8" ;
5107
5088
}
5108
5089
else {
5109
5090
goodprint " gcs.fc_factor is equal to 0.8" ;
5110
5091
}
5111
- if ( get_wsrep_option(' wsrep_flow_control_paused' ) > 0.02 ) {
5092
+ if ( get_wsrep_option(' wsrep_flow_control_paused' ) > 0.02 ) {
5112
5093
badprint " Fraction of time node pause flow control > 0.02" ;
5113
- }
5114
- else {
5115
- goodprint
5116
- " Flow control fraction seems to be OK (wsrep_flow_control_paused<=0.02)" ;
5094
+ } else {
5095
+ goodprint " Flow control fraction seems to be OK (wsrep_flow_control_paused<=0.02)" ;
5117
5096
}
5118
5097
5119
5098
if ( scalar (@primaryKeysNbTables ) > 0 ) {
@@ -5122,8 +5101,7 @@ sub mariadb_galera {
5122
5101
badprint " \t $badtable " ;
5123
5102
push @{ $result {' Tables without PK' } }, $badtable ;
5124
5103
}
5125
- }
5126
- else {
5104
+ } else {
5127
5105
goodprint " All tables get a primary key" ;
5128
5106
}
5129
5107
my @nonInnoDBTables = select_array(
@@ -5136,22 +5114,19 @@ sub mariadb_galera {
5136
5114
foreach my $badtable (@nonInnoDBTables ) {
5137
5115
badprint " \t $badtable " ;
5138
5116
}
5139
- }
5140
- else {
5117
+ } else {
5141
5118
goodprint " All tables are InnoDB tables" ;
5142
5119
}
5143
5120
if ( $myvar {' binlog_format' } ne ' ROW' ) {
5144
5121
badprint " Binlog format should be in ROW mode." ;
5145
5122
push @adjvars , " binlog_format = ROW" ;
5146
- }
5147
- else {
5123
+ } else {
5148
5124
goodprint " Binlog format is in ROW mode." ;
5149
5125
}
5150
5126
if ( $myvar {' innodb_flush_log_at_trx_commit' } != 0 ) {
5151
5127
badprint " InnoDB flush log at each commit should be disabled." ;
5152
5128
push @adjvars , " innodb_flush_log_at_trx_commit = 0" ;
5153
- }
5154
- else {
5129
+ } else {
5155
5130
goodprint " InnoDB flush log at each commit is disabled for Galera." ;
5156
5131
}
5157
5132
@@ -5417,7 +5392,7 @@ sub mysql_innodb {
5417
5392
. " should be equal 25%" ;
5418
5393
push (
5419
5394
@adjvars ,
5420
- " innodb_log_file_size * innodb_log_files_in_group should be equals to 1/4 of buffer pool size (="
5395
+ " innodb_log_file_size * innodb_log_files_in_group should be equal to 1/4 of buffer pool size (="
5421
5396
. hr_bytes_rnd(
5422
5397
$myvar {' innodb_buffer_pool_size' } *
5423
5398
$myvar {' innodb_log_files_in_group' } / 4
@@ -5840,13 +5815,13 @@ sub mysql_indexes {
5840
5815
infoprint " +-- TYPE : " . $info [6];
5841
5816
infoprint " +-- SELECTIVITY : " . $info [7] . " %" ;
5842
5817
5843
- $result {' Indexes' }{ $info [1] }{' Column' } = $info [0];
5844
- $result {' Indexes' }{ $info [1] }{' Sequence number' } = $info [2];
5845
- $result {' Indexes' }{ $info [1] }{' Number of column' } = $info [3];
5846
- $result {' Indexes' }{ $info [1] }{' Cardinality' } = $info [4];
5847
- $result {' Indexes' }{ $info [1] }{' Row number' } = $info [5];
5848
- $result {' Indexes' }{ $info [1] }{' Index Type' } = $info [6];
5849
- $result {' Indexes' }{ $info [1] }{' Selectivity' } = $info [7];
5818
+ $result {' Indexes' }{ $info [1] }{' Column' } = $info [0];
5819
+ $result {' Indexes' }{ $info [1] }{' Sequence number' } = $info [2];
5820
+ $result {' Indexes' }{ $info [1] }{' Number of column' } = $info [3];
5821
+ $result {' Indexes' }{ $info [1] }{' Cardinality' } = $info [4];
5822
+ $result {' Indexes' }{ $info [1] }{' Row number' } = $info [5];
5823
+ $result {' Indexes' }{ $info [1] }{' Index Type' } = $info [6];
5824
+ $result {' Indexes' }{ $info [1] }{' Selectivity' } = $info [7];
5850
5825
if ( $info [7] < 25 ) {
5851
5826
badprint " $info [1] has a low selectivity" ;
5852
5827
}
@@ -5942,7 +5917,6 @@ sub file2string {
5942
5917
$templateModel = file2string( $opt {' template' } );
5943
5918
}
5944
5919
else {
5945
-
5946
5920
# DEFAULT REPORT TEMPLATE
5947
5921
$templateModel = <<'END_TEMPLATE' ;
5948
5922
<!DOCTYPE html>
@@ -6063,7 +6037,6 @@ sub which {
6063
6037
1;
6064
6038
6065
6039
__END__
6066
-
6067
6040
=pod
6068
6041
6069
6042
=encoding UTF-8
0 commit comments