This commit is contained in:
root 2016-12-08 11:29:59 +01:00
commit 7f02c8655c

View file

@ -1106,39 +1106,39 @@ sub get_basic_passwords {
sub log_file_recommandations { sub log_file_recommandations {
subheaderprint "Log file Recommendations"; subheaderprint "Log file Recommendations";
infoprint "Log file: " . $myvar{'log_error'}. "(".hr_bytes_rnd((stat $myvar{'log_error'})[7]).")"; infoprint "Log file: " . $myvar{'log_error'}. "(".hr_bytes_rnd((stat $myvar{'log_error'})[7]).")";
if (-f "$myvar{'log_error'}") { if ( -f "$myvar{'log_error'}" ) {
goodprint "Log file $myvar{'log_error'} exists"; goodprint "Log file $myvar{'log_error'} exists";
} else { } else {
badprint "Log file $myvar{'log_error'} doesn't exist"; badprint "Log file $myvar{'log_error'} doesn't exist";
} }
if (-r "$myvar{'log_error'}") { if ( -r "$myvar{'log_error'}" ) {
goodprint "Log file $myvar{'log_error'} is readable."; goodprint "Log file $myvar{'log_error'} is readable.";
} else { } else {
badprint "Log file $myvar{'log_error'} isn't readable."; badprint "Log file $myvar{'log_error'} isn't readable.";
return; return;
} }
if ( (stat $myvar{'log_error'})[7] > 0) { if ( (stat $myvar{'log_error'})[7] > 0 ) {
goodprint "Log file $myvar{'log_error'} is not empty"; goodprint "Log file $myvar{'log_error'} is not empty";
} else { } else {
badprint "Log file $myvar{'log_error'} is empty"; badprint "Log file $myvar{'log_error'} is empty";
} }
if ( (stat $myvar{'log_error'})[7] < 32*1024*1024) { if ( (stat $myvar{'log_error'})[7] < 32*1024*1024 ) {
goodprint "Log file $myvar{'log_error'} is smaller than 32 Mb"; goodprint "Log file $myvar{'log_error'} is smaller than 32 Mb";
} else { } else {
badprint "Log file $myvar{'log_error'} is bigger than 32 Mb"; badprint "Log file $myvar{'log_error'} is bigger than 32 Mb";
push( @generalrec, push @generalrec,
$myvar{'log_error'} ."is > 32Mb, you should analyze why or implement a rotation log strategy such as logrotate!" ); $myvar{'log_error'} ."is > 32Mb, you should analyze why or implement a rotation log strategy such as logrotate!" ;
} }
my @log_content=get_file_contents($myvar{'log_error'}); my @log_content = get_file_contents($myvar{'log_error'});
my $numLi=0; my $numLi = 0;
my $nbWarnLog=0; my $nbWarnLog = 0;
my $nbErrLog=0; my $nbErrLog = 0;
my @lastShutdowns; my @lastShutdowns;
my @lastStarts; my @lastStarts;
foreach my $logLi(@log_content) { foreach my $logLi ( @log_content ) {
$numLi++; $numLi++;
debugprint "$numLi: $logLi" if $logLi =~ /warning|error/i; debugprint "$numLi: $logLi" if $logLi =~ /warning|error/i;
$nbErrLog++ if $logLi =~ /error/i; $nbErrLog++ if $logLi =~ /error/i;
@ -1146,30 +1146,38 @@ sub log_file_recommandations {
push @lastShutdowns, $logLi if $logLi =~ /Shutdown complete/ and $logLi !~ /Innodb/i; push @lastShutdowns, $logLi if $logLi =~ /Shutdown complete/ and $logLi !~ /Innodb/i;
push @lastStarts, $logLi if $logLi =~ /ready for connections/; push @lastStarts, $logLi if $logLi =~ /ready for connections/;
} }
if ($nbWarnLog > 0) { if ( $nbWarnLog > 0 ) {
badprint "$myvar{'log_error'} contains $nbWarnLog warning(s)."; badprint "$myvar{'log_error'} contains $nbWarnLog warning(s).";
push( @generalrec, "Control warning line(s) into $myvar{'log_error'} file"); push @generalrec, "Control warning line(s) into $myvar{'log_error'} file";
} else { } else {
goodprint "$myvar{'log_error'} doesn't contain any warning."; goodprint "$myvar{'log_error'} doesn't contain any warning.";
} }
if ($nbErrLog > 0) { if ( $nbErrLog > 0 ) {
badprint "$myvar{'log_error'} contains $nbErrLog error(s)."; badprint "$myvar{'log_error'} contains $nbErrLog error(s).";
push( @generalrec, "Control error line(s) into $myvar{'log_error'} file"); push @generalrec, "Control error line(s) into $myvar{'log_error'} file";
} else { } else {
goodprint "$myvar{'log_error'} doesn't contain any error."; goodprint "$myvar{'log_error'} doesn't contain any error.";
} }
infoprint scalar(@lastStarts). " start(s) detected in $myvar{'log_error'}"; infoprint scalar @lastStarts . " start(s) detected in $myvar{'log_error'}";
my $nStart=0; my $nStart = 0;
for my $startd (reverse @lastStarts[-10..-1]) { my $nEnd = 10;
if ( scalar @lastStarts < $nEnd ) {
$nEnd = scalar @lastStarts;
}
for my $startd ( reverse @lastStarts[-$nEnd..-1] ) {
$nStart++; $nStart++;
infoprint "$nStart) $startd"; infoprint "$nStart) $startd";
} }
infoprint scalar(@lastShutdowns). " shutdown(s) detected in $myvar{'log_error'}"; infoprint scalar @lastShutdowns . " shutdown(s) detected in $myvar{'log_error'}";
my $nShut=0; $nStart=0;
for my $shutd (reverse @lastShutdowns[-10..-1]) { $nEnd=10;
$nShut++; if ( scalar @lastShutdowns < $nEnd ) {
infoprint "$nShut) $shutd"; $nEnd = scalar @lastShutdowns;
}
for my $shutd ( reverse @lastShutdowns[-$nEnd..-1] ) {
$nStart++;
infoprint "$nStart) $shutd";
} }
#exit 0; #exit 0;
} }
@ -2736,16 +2744,9 @@ sub mysql_stats {
push( @generalrec, push( @generalrec,
"Upgrade MySQL to version 4+ to utilize query caching" ); "Upgrade MySQL to version 4+ to utilize query caching" );
} }
elsif ( mysql_version_ge( 5, 5 ) and !mysql_version_ge( 10, 1 ) ) { elsif ( mysql_version_ge( 5, 5 ) and !mysql_version_ge( 10, 1 ) and $myvar{'query_cache_type'} eq "OFF" ) {
if ( $myvar{'query_cache_type'} ne "OFF" ) {
badprint
"Query cache may be disabled by default due to mutex contention.";
push( @adjvars, "query_cache_type (=0)" );
}
else {
goodprint goodprint
"Query cache is disabled by default due to mutex contention on multiprocessor machines."; "Query cache is disabled by default due to mutex contention on multiprocessor machines.";
}
} }
elsif ( $myvar{'query_cache_size'} < 1 ) { elsif ( $myvar{'query_cache_size'} < 1 ) {
badprint "Query cache is disabled"; badprint "Query cache is disabled";
@ -2760,6 +2761,9 @@ sub mysql_stats {
"Query cache cannot be analyzed - no SELECT statements executed"; "Query cache cannot be analyzed - no SELECT statements executed";
} }
else { else {
badprint
"Query cache may be disabled by default due to mutex contention.";
push( @adjvars, "query_cache_type (=0)" );
if ( $mycalc{'query_cache_efficiency'} < 20 ) { if ( $mycalc{'query_cache_efficiency'} < 20 ) {
badprint badprint
"Query cache efficiency: $mycalc{'query_cache_efficiency'}% (" "Query cache efficiency: $mycalc{'query_cache_efficiency'}% ("