improve FreeBSD support a bit (patch included) #549
This commit is contained in:
parent
52d3fc4d7c
commit
213211aecc
1 changed files with 30 additions and 11 deletions
|
@ -1,5 +1,5 @@
|
||||||
#!/usr/bin/env perl
|
#!/usr/bin/env perl
|
||||||
# mysqltuner.pl - Version 1.7.27
|
# mysqltuner.pl - Version 1.7.28
|
||||||
# High Performance MySQL Tuning Script
|
# High Performance MySQL Tuning Script
|
||||||
# Copyright (C) 2006-2021 Major Hayden - major@mhtx.net
|
# Copyright (C) 2006-2021 Major Hayden - major@mhtx.net
|
||||||
#
|
#
|
||||||
|
@ -56,7 +56,7 @@ $Data::Dumper::Pair = " : ";
|
||||||
#use Env;
|
#use Env;
|
||||||
|
|
||||||
# Set up a few variables for use in the script
|
# Set up a few variables for use in the script
|
||||||
my $tunerversion = "1.7.27";
|
my $tunerversion = "1.7.28";
|
||||||
my ( @adjvars, @generalrec );
|
my ( @adjvars, @generalrec );
|
||||||
|
|
||||||
# Set defaults
|
# Set defaults
|
||||||
|
@ -300,11 +300,20 @@ sub infoprinthcmd {
|
||||||
|
|
||||||
# Calculates the number of physical cores considering HyperThreading
|
# Calculates the number of physical cores considering HyperThreading
|
||||||
sub cpu_cores {
|
sub cpu_cores {
|
||||||
|
if ($^O eq 'linux') {
|
||||||
my $cntCPU =
|
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`;
|
`awk -F: '/^core id/ && !P[\$2] { CORES++; P[\$2]=1 }; /^physical id/ && !N[\$2] { CPUs++; N[\$2]=1 }; END { print CPUs*CORES }' /proc/cpuinfo`;
|
||||||
return ( $cntCPU == 0 ? `nproc` : $cntCPU );
|
return ( $cntCPU == 0 ? `nproc` : $cntCPU );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ($^O eq 'freebsd') {
|
||||||
|
my $cntCPU = `sysctl -n kern.smp.cores`;
|
||||||
|
chomp $cntCPU;
|
||||||
|
return $cntCPU + 0;
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
# Calculates the parameter passed in bytes, then rounds it to one decimal place
|
# Calculates the parameter passed in bytes, then rounds it to one decimal place
|
||||||
sub hr_bytes {
|
sub hr_bytes {
|
||||||
my $num = shift;
|
my $num = shift;
|
||||||
|
@ -1169,7 +1178,7 @@ sub get_all_vars {
|
||||||
debugprint Dumper(@mysqlenginelist);
|
debugprint Dumper(@mysqlenginelist);
|
||||||
|
|
||||||
my @mysqlslave;
|
my @mysqlslave;
|
||||||
if ($mysqlvermajor eq 8 or ($mysqlvermajor eq 10 and $mysqlverminor ge 5)) {
|
if ( mysql_version_eq( 8 ) or mysql_version_ge( 10, 5 ) ) {
|
||||||
@mysqlslave = select_array("SHOW SLAVE STATUS\\G");
|
@mysqlslave = select_array("SHOW SLAVE STATUS\\G");
|
||||||
} else {
|
} else {
|
||||||
@mysqlslave = select_array("SHOW REPLICA STATUS\\G");
|
@mysqlslave = select_array("SHOW REPLICA STATUS\\G");
|
||||||
|
@ -1178,7 +1187,7 @@ sub get_all_vars {
|
||||||
$result{'Replication'}{'Status'} = \%myrepl;
|
$result{'Replication'}{'Status'} = \%myrepl;
|
||||||
|
|
||||||
my @mysqlslaves;
|
my @mysqlslaves;
|
||||||
if ( $mysqlvermajor eq 8 or ($mysqlvermajor eq 10 and $mysqlverminor ge 5) ) {
|
if ( mysql_version_eq( 8 ) or mysql_version_ge( 10, 5 ) ) {
|
||||||
@mysqlslaves= select_array "SHOW SLAVE HOSTS";
|
@mysqlslaves= select_array "SHOW SLAVE HOSTS";
|
||||||
} else {
|
} else {
|
||||||
@mysqlslaves = select_array("SHOW SLAVE STATUS\\G");
|
@mysqlslaves = select_array("SHOW SLAVE STATUS\\G");
|
||||||
|
@ -1578,10 +1587,20 @@ sub merge_hash {
|
||||||
}
|
}
|
||||||
|
|
||||||
sub is_virtual_machine {
|
sub is_virtual_machine {
|
||||||
|
if ($^O eq 'linux') {
|
||||||
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 );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ($^O eq 'freebsd') {
|
||||||
|
my $isVm = `sysctl -n kern.vm_guest`;
|
||||||
|
chomp $isVm;
|
||||||
|
print "FARK DEBUG isVm=[$isVm]";
|
||||||
|
return ( $isVm eq 'none' ? 0 : 1);
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
sub infocmd {
|
sub infocmd {
|
||||||
my $cmd = "@_";
|
my $cmd = "@_";
|
||||||
debugprint "CMD: $cmd";
|
debugprint "CMD: $cmd";
|
||||||
|
@ -6511,7 +6530,7 @@ __END__
|
||||||
|
|
||||||
=head1 NAME
|
=head1 NAME
|
||||||
|
|
||||||
MySQLTuner 1.7.27 - MySQL High Performance Tuning Script
|
MySQLTuner 1.7.28 - MySQL High Performance Tuning Script
|
||||||
|
|
||||||
=head1 IMPORTANT USAGE GUIDELINES
|
=head1 IMPORTANT USAGE GUIDELINES
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue