bug fix in calculate greater and lower version
This commit is contained in:
parent
8e8345dac3
commit
11ccfccc1c
1 changed files with 26 additions and 12 deletions
|
@ -226,6 +226,9 @@ my $deb = ( $opt{nocolor} == 0 ) ? "[\e[0;31mDG\e[0m]" : "[DG]";
|
||||||
my $cmd = ( $opt{nocolor} == 0 ) ? "\e[1;32m[CMD]($me)" : "[CMD]($me)";
|
my $cmd = ( $opt{nocolor} == 0 ) ? "\e[1;32m[CMD]($me)" : "[CMD]($me)";
|
||||||
my $end = ( $opt{nocolor} == 0 ) ? "\e[0m" : "";
|
my $end = ( $opt{nocolor} == 0 ) ? "\e[0m" : "";
|
||||||
|
|
||||||
|
# Checks for supported or EOL'ed MySQL versions
|
||||||
|
my ( $mysqlvermajor, $mysqlverminor, $mysqlvermicro );
|
||||||
|
|
||||||
# Super structure containing all information
|
# Super structure containing all information
|
||||||
my %result;
|
my %result;
|
||||||
$result{'MySQLTuner'}{'version'}=$tunerversion;
|
$result{'MySQLTuner'}{'version'}=$tunerversion;
|
||||||
|
@ -1051,7 +1054,17 @@ sub cve_recommendations {
|
||||||
open( FH, "<$opt{cvefile}" ) or die "Can't open $opt{cvefile} for read: $!";
|
open( FH, "<$opt{cvefile}" ) or die "Can't open $opt{cvefile} for read: $!";
|
||||||
while ( my $cveline = <FH> ) {
|
while ( my $cveline = <FH> ) {
|
||||||
my @cve = split( ';', $cveline );
|
my @cve = split( ';', $cveline );
|
||||||
if ( mysql_micro_version_le( $cve[1], $cve[2], $cve[3] ) ) {
|
debugprint "Comparing $mysqlvermajor\.$mysqlverminor\.$mysqlvermicro with $cve[1]\.$cve[2]\.$cve[3] : ".(mysql_version_le( $cve[1], $cve[2], $cve[3] )?'<=':'>');
|
||||||
|
|
||||||
|
# Fix some false positive in CVS parsing
|
||||||
|
next if (int($cve[1]) > 10 or int($cve[1]) == 6 or int($cve[1]) < 3);
|
||||||
|
|
||||||
|
# Removing 10.X.X CVE when version is a 3, 4 or 5 MySQL
|
||||||
|
next if ( ( int($mysqlvermajor) == 3 ||
|
||||||
|
int($mysqlvermajor) == 4 ||
|
||||||
|
int($mysqlvermajor) == 5 ) && int($cve[1]) == 10);
|
||||||
|
|
||||||
|
if ( mysql_version_le( $cve[1], $cve[2], $cve[3] ) ) {
|
||||||
badprint "$cve[4] : $cve[6]";
|
badprint "$cve[4] : $cve[6]";
|
||||||
$result{'CVE'}{'List'}{$cvefound}="$cve[4] : $cve[6]";
|
$result{'CVE'}{'List'}{$cvefound}="$cve[4] : $cve[6]";
|
||||||
$cvefound++;
|
$cvefound++;
|
||||||
|
@ -1257,7 +1270,7 @@ sub get_kernel_info() {
|
||||||
|
|
||||||
# only if /proc/sys/sunrpc exists
|
# only if /proc/sys/sunrpc exists
|
||||||
my $tcp_slot_entries=`sysctl -n sunrpc.tcp_slot_table_entries 2>/dev/null`;
|
my $tcp_slot_entries=`sysctl -n sunrpc.tcp_slot_table_entries 2>/dev/null`;
|
||||||
if ( -f "/proc/sys/sunrpc" and $tcp_slot_entries eq '' or $tcp_slot_entries < 100 ) {
|
if ( -f "/proc/sys/sunrpc" and ($tcp_slot_entries eq '' or $tcp_slot_entries < 100) ) {
|
||||||
badprint
|
badprint
|
||||||
"Initial TCP slot entries is < 1M, please consider having a value greater than 100";
|
"Initial TCP slot entries is < 1M, please consider having a value greater than 100";
|
||||||
push @generalrec, "setup Initial TCP slot entries greater than 100";
|
push @generalrec, "setup Initial TCP slot entries greater than 100";
|
||||||
|
@ -1606,9 +1619,6 @@ sub get_replication_status {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
# Checks for supported or EOL'ed MySQL versions
|
|
||||||
my ( $mysqlvermajor, $mysqlverminor, $mysqlvermicro );
|
|
||||||
|
|
||||||
sub validate_mysql_version {
|
sub validate_mysql_version {
|
||||||
( $mysqlvermajor, $mysqlverminor, $mysqlvermicro ) =
|
( $mysqlvermajor, $mysqlverminor, $mysqlvermicro ) =
|
||||||
$myvar{'version'} =~ /^(\d+)(?:\.(\d+)|)(?:\.(\d+)|)/;
|
$myvar{'version'} =~ /^(\d+)(?:\.(\d+)|)(?:\.(\d+)|)/;
|
||||||
|
@ -1636,9 +1646,9 @@ sub mysql_version_ge {
|
||||||
my ( $maj, $min, $mic ) = @_;
|
my ( $maj, $min, $mic ) = @_;
|
||||||
$min ||= 0;
|
$min ||= 0;
|
||||||
$mic ||= 0;
|
$mic ||= 0;
|
||||||
return $mysqlvermajor > $maj
|
return int($mysqlvermajor) > int($maj)
|
||||||
|| $mysqlvermajor == $maj && ( $mysqlverminor > $min
|
|| ( int($mysqlvermajor) == int($maj) && int($mysqlverminor) > int($min) )
|
||||||
|| $mysqlverminor == $min && $mysqlvermicro >= $mic );
|
|| ( int($mysqlverminor) == int($min) && int($mysqlvermicro) >= int($mic) );
|
||||||
}
|
}
|
||||||
|
|
||||||
# Checks if MySQL version is lower than equal to (major, minor, micro)
|
# Checks if MySQL version is lower than equal to (major, minor, micro)
|
||||||
|
@ -1646,9 +1656,9 @@ sub mysql_version_le {
|
||||||
my ( $maj, $min, $mic ) = @_;
|
my ( $maj, $min, $mic ) = @_;
|
||||||
$min ||= 0;
|
$min ||= 0;
|
||||||
$mic ||= 0;
|
$mic ||= 0;
|
||||||
return $mysqlvermajor < $maj
|
return int($mysqlvermajor) < int($maj)
|
||||||
|| $mysqlvermajor == $maj && ( $mysqlverminor < $min
|
|| ( int($mysqlvermajor) == int($maj) && int($mysqlverminor) < int($min) )
|
||||||
|| $mysqlverminor == $min && $mysqlvermicro <= $mic );
|
|| ( int($mysqlverminor) == int($min) && int($mysqlvermicro) <= int($mic) );
|
||||||
}
|
}
|
||||||
|
|
||||||
# Checks if MySQL micro version is lower than equal to (major, minor, micro)
|
# Checks if MySQL micro version is lower than equal to (major, minor, micro)
|
||||||
|
@ -1790,7 +1800,9 @@ sub check_storage_engines {
|
||||||
my ( $engine, $size, $count, $dsize, $isize );
|
my ( $engine, $size, $count, $dsize, $isize );
|
||||||
foreach my $line (@templist) {
|
foreach my $line (@templist) {
|
||||||
( $engine, $size, $count, $dsize, $isize ) =
|
( $engine, $size, $count, $dsize, $isize ) =
|
||||||
$line =~ /([a-zA-Z_]*)\s+(\d+)\s+(\d+)\s+(\d+)\s+(\d+)/;
|
$line =~ /([a-zA-Z_]+)\s+(\d+)\s+(\d+)\s+(\d+)\s+(\d+)/;
|
||||||
|
debugprint "Engine Found: $engine";
|
||||||
|
next unless (defined($engine));
|
||||||
$size=0 unless defined($size);
|
$size=0 unless defined($size);
|
||||||
$isize=0 unless defined($isize);
|
$isize=0 unless defined($isize);
|
||||||
$dsize=0 unless defined($dsize);
|
$dsize=0 unless defined($dsize);
|
||||||
|
@ -4084,6 +4096,8 @@ os_setup; # Set up some OS variables
|
||||||
get_all_vars; # Toss variables/status into hashes
|
get_all_vars; # Toss variables/status into hashes
|
||||||
get_tuning_info; # Get information about the tuning connexion
|
get_tuning_info; # Get information about the tuning connexion
|
||||||
validate_mysql_version; # Check current MySQL version
|
validate_mysql_version; # Check current MySQL version
|
||||||
|
|
||||||
|
|
||||||
check_architecture; # Suggest 64-bit upgrade
|
check_architecture; # Suggest 64-bit upgrade
|
||||||
system_recommendations; # avoid to many service on the same host
|
system_recommendations; # avoid to many service on the same host
|
||||||
check_storage_engines; # Show enabled storage engines
|
check_storage_engines; # Show enabled storage engines
|
||||||
|
|
Loading…
Reference in a new issue