1
1
# !/usr/bin/env perl
2
- # mysqltuner.pl - Version 1.7.27
2
+ # mysqltuner.pl - Version 1.7.28
3
3
# High Performance MySQL Tuning Script
4
4
# Copyright (C) 2006-2021 Major Hayden - major@mhtx.net
5
5
#
@@ -56,7 +56,7 @@ package main;
56
56
# use Env;
57
57
58
58
# Set up a few variables for use in the script
59
- my $tunerversion = " 1.7.27 " ;
59
+ my $tunerversion = " 1.7.28 " ;
60
60
my ( @adjvars , @generalrec );
61
61
62
62
# Set defaults
@@ -300,9 +300,18 @@ sub infoprinthcmd {
300
300
301
301
# Calculates the number of physical cores considering HyperThreading
302
302
sub cpu_cores {
303
- my $cntCPU =
304
- ` 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
- return ( $cntCPU == 0 ? ` nproc` : $cntCPU );
303
+ if ($^O eq ' linux' ) {
304
+ my $cntCPU =
305
+ ` awk -F: '/^core id/ && !P[\$ 2] { CORES++; P[\$ 2]=1 }; /^physical id/ && !N[\$ 2] { CPUs++; N[\$ 2]=1 }; END { print CPUs*CORES }' /proc/cpuinfo` ;
306
+ return ( $cntCPU == 0 ? ` nproc` : $cntCPU );
307
+ }
308
+
309
+ if ($^O eq ' freebsd' ) {
310
+ my $cntCPU = ` sysctl -n kern.smp.cores` ;
311
+ chomp $cntCPU ;
312
+ return $cntCPU + 0;
313
+ }
314
+ return 0;
306
315
}
307
316
308
317
# Calculates the parameter passed in bytes, then rounds it to one decimal place
@@ -1169,7 +1178,7 @@ sub get_all_vars {
1169
1178
debugprint Dumper(@mysqlenginelist );
1170
1179
1171
1180
my @mysqlslave ;
1172
- if ($mysqlvermajor eq 8 or ( $mysqlvermajor eq 10 and $mysqlverminor ge 5) ) {
1181
+ if ( mysql_version_eq( 8 ) or mysql_version_ge( 10, 5 ) ) {
1173
1182
@mysqlslave = select_array(" SHOW SLAVE STATUS\\ G" );
1174
1183
} else {
1175
1184
@mysqlslave = select_array(" SHOW REPLICA STATUS\\ G" );
@@ -1178,7 +1187,7 @@ sub get_all_vars {
1178
1187
$result {' Replication' }{' Status' } = \%myrepl ;
1179
1188
1180
1189
my @mysqlslaves ;
1181
- if ( $mysqlvermajor eq 8 or ( $mysqlvermajor eq 10 and $mysqlverminor ge 5 ) ) {
1190
+ if ( mysql_version_eq( 8 ) or mysql_version_ge( 10, 5 ) ) {
1182
1191
@mysqlslaves = select_array " SHOW SLAVE HOSTS" ;
1183
1192
} else {
1184
1193
@mysqlslaves = select_array(" SHOW SLAVE STATUS\\ G" );
@@ -1578,9 +1587,19 @@ sub merge_hash {
1578
1587
}
1579
1588
1580
1589
sub is_virtual_machine {
1581
- my $isVm = ` grep -Ec '^flags.*\ hypervisor\ ' /proc/cpuinfo` ;
1582
- return ( $isVm == 0 ? 0 : 1 );
1583
- }
1590
+ if ($^O eq ' linux' ) {
1591
+ my $isVm = ` grep -Ec '^flags.*\ hypervisor\ ' /proc/cpuinfo` ;
1592
+ return ( $isVm == 0 ? 0 : 1 );
1593
+ }
1594
+
1595
+ if ($^O eq ' freebsd' ) {
1596
+ my $isVm = ` sysctl -n kern.vm_guest` ;
1597
+ chomp $isVm ;
1598
+ print " FARK DEBUG isVm=[$isVm ]" ;
1599
+ return ( $isVm eq ' none' ? 0 : 1);
1600
+ }
1601
+ return 0;
1602
+ }
1584
1603
1585
1604
sub infocmd {
1586
1605
my $cmd = " @_ " ;
@@ -6511,7 +6530,7 @@ sub which {
6511
6530
6512
6531
=head1 NAME
6513
6532
6514
- MySQLTuner 1.7.27 - MySQL High Performance Tuning Script
6533
+ MySQLTuner 1.7.28 - MySQL High Performance Tuning Script
6515
6534
6516
6535
=head1 IMPORTANT USAGE GUIDELINES
6517
6536
0 commit comments