fix code style in log_file_recommandations
This commit is contained in:
parent
d3ea7ea342
commit
4bc3a50c2d
1 changed files with 59 additions and 59 deletions
|
@ -1106,39 +1106,39 @@ sub get_basic_passwords {
|
|||
sub log_file_recommandations {
|
||||
subheaderprint "Log file Recommendations";
|
||||
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";
|
||||
} else {
|
||||
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.";
|
||||
} else {
|
||||
badprint "Log file $myvar{'log_error'} isn't readable.";
|
||||
return;
|
||||
}
|
||||
if ( (stat $myvar{'log_error'})[7] > 0) {
|
||||
if ( (stat $myvar{'log_error'})[7] > 0 ) {
|
||||
goodprint "Log file $myvar{'log_error'} is not empty";
|
||||
} else {
|
||||
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";
|
||||
} else {
|
||||
badprint "Log file $myvar{'log_error'} is bigger than 32 Mb";
|
||||
push( @generalrec,
|
||||
$myvar{'log_error'} ."is > 32Mb, you should analyze why or implement a rotation log strategy such as logrotate!" );
|
||||
push @generalrec,
|
||||
$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 $nbWarnLog=0;
|
||||
my $nbErrLog=0;
|
||||
my $numLi = 0;
|
||||
my $nbWarnLog = 0;
|
||||
my $nbErrLog = 0;
|
||||
my @lastShutdowns;
|
||||
my @lastStarts;
|
||||
foreach my $logLi(@log_content) {
|
||||
foreach my $logLi ( @log_content ) {
|
||||
$numLi++;
|
||||
debugprint "$numLi: $logLi" if $logLi =~ /warning|error/i;
|
||||
$nbErrLog++ if $logLi =~ /error/i;
|
||||
|
@ -1146,36 +1146,36 @@ sub log_file_recommandations {
|
|||
push @lastShutdowns, $logLi if $logLi =~ /Shutdown complete/ and $logLi !~ /Innodb/i;
|
||||
push @lastStarts, $logLi if $logLi =~ /ready for connections/;
|
||||
}
|
||||
if ($nbWarnLog > 0) {
|
||||
if ( $nbWarnLog > 0 ) {
|
||||
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 {
|
||||
goodprint "$myvar{'log_error'} doesn't contain any warning.";
|
||||
}
|
||||
if ($nbErrLog > 0) {
|
||||
if ( $nbErrLog > 0 ) {
|
||||
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 {
|
||||
goodprint "$myvar{'log_error'} doesn't contain any error.";
|
||||
}
|
||||
|
||||
infoprint scalar(@lastStarts). " start(s) detected in $myvar{'log_error'}";
|
||||
my $nStart=0;
|
||||
infoprint scalar @lastStarts . " start(s) detected in $myvar{'log_error'}";
|
||||
my $nStart = 0;
|
||||
my $nEnd = 10;
|
||||
if (scalar(@lastStarts) < $nEnd) {
|
||||
$nEnd = scalar(@lastStarts);
|
||||
if ( scalar @lastStarts < $nEnd ) {
|
||||
$nEnd = scalar @lastStarts;
|
||||
}
|
||||
for my $startd (reverse @lastStarts[-$nEnd..-1]) {
|
||||
for my $startd ( reverse @lastStarts[-$nEnd..-1] ) {
|
||||
$nStart++;
|
||||
infoprint "$nStart) $startd";
|
||||
}
|
||||
infoprint scalar(@lastShutdowns). " shutdown(s) detected in $myvar{'log_error'}";
|
||||
infoprint scalar @lastShutdowns . " shutdown(s) detected in $myvar{'log_error'}";
|
||||
$nStart=0;
|
||||
$nEnd=10;
|
||||
if (scalar(@lastShutdowns) < $nEnd) {
|
||||
$nEnd = scalar(@lastShutdowns);
|
||||
if ( scalar @lastShutdowns < $nEnd ) {
|
||||
$nEnd = scalar @lastShutdowns;
|
||||
}
|
||||
for my $shutd (reverse @lastShutdowns[-$nEnd..-1]) {
|
||||
for my $shutd ( reverse @lastShutdowns[-$nEnd..-1] ) {
|
||||
$nStart++;
|
||||
infoprint "$nStart) $shutd";
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue