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 {
|
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,36 +1146,36 @@ 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;
|
||||||
my $nEnd = 10;
|
my $nEnd = 10;
|
||||||
if (scalar(@lastStarts) < $nEnd) {
|
if ( scalar @lastStarts < $nEnd ) {
|
||||||
$nEnd = scalar(@lastStarts);
|
$nEnd = scalar @lastStarts;
|
||||||
}
|
}
|
||||||
for my $startd (reverse @lastStarts[-$nEnd..-1]) {
|
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'}";
|
||||||
$nStart=0;
|
$nStart=0;
|
||||||
$nEnd=10;
|
$nEnd=10;
|
||||||
if (scalar(@lastShutdowns) < $nEnd) {
|
if ( scalar @lastShutdowns < $nEnd ) {
|
||||||
$nEnd = scalar(@lastShutdowns);
|
$nEnd = scalar @lastShutdowns;
|
||||||
}
|
}
|
||||||
for my $shutd (reverse @lastShutdowns[-$nEnd..-1]) {
|
for my $shutd ( reverse @lastShutdowns[-$nEnd..-1] ) {
|
||||||
$nStart++;
|
$nStart++;
|
||||||
infoprint "$nStart) $shutd";
|
infoprint "$nStart) $shutd";
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue