|
|
dc8c34 |
From f2d2ce977345edd9cd61eb8857c0ce527cee11d2 Mon Sep 17 00:00:00 2001
|
|
|
dc8c34 |
From: Mark Reynolds <mreynolds@redhat.com>
|
|
|
dc8c34 |
Date: Tue, 27 May 2014 10:57:32 -0400
|
|
|
dc8c34 |
Subject: [PATCH 215/225] Ticket 47713 - Logconv.pl with an empty access log
|
|
|
dc8c34 |
gives lots of errors
|
|
|
dc8c34 |
|
|
|
dc8c34 |
Description: Was missing a check to see if a log file was empty,
|
|
|
dc8c34 |
also fixed some "experimental" warnings in perl 5.18
|
|
|
dc8c34 |
caused by the use of "my $_".
|
|
|
dc8c34 |
|
|
|
dc8c34 |
https://fedorahosted.org/389/ticket/47713
|
|
|
dc8c34 |
|
|
|
dc8c34 |
Reviewed by: nhosoi(Thanks!)
|
|
|
dc8c34 |
|
|
|
dc8c34 |
(cherry picked from commit c476d41935397f250f6d942dc653851b82019953)
|
|
|
dc8c34 |
(cherry picked from commit 147238158be0a0a2303d90235ab62b6c6e1f2e4b)
|
|
|
dc8c34 |
(cherry picked from commit 8155bea1a706fb1870036c6be2202c6a01dd6dde)
|
|
|
dc8c34 |
---
|
|
|
dc8c34 |
ldap/admin/src/logconv.pl | 35 ++++++++++++++++++++++++-----------
|
|
|
dc8c34 |
1 file changed, 24 insertions(+), 11 deletions(-)
|
|
|
dc8c34 |
|
|
|
dc8c34 |
diff --git a/ldap/admin/src/logconv.pl b/ldap/admin/src/logconv.pl
|
|
|
dc8c34 |
index 99e0efd..ea33544 100755
|
|
|
dc8c34 |
--- a/ldap/admin/src/logconv.pl
|
|
|
dc8c34 |
+++ b/ldap/admin/src/logconv.pl
|
|
|
dc8c34 |
@@ -196,8 +196,8 @@ if ($sizeCount eq "all"){$sizeCount = "100000";}
|
|
|
dc8c34 |
# #
|
|
|
dc8c34 |
#######################################
|
|
|
dc8c34 |
|
|
|
dc8c34 |
-print "\nAccess Log Analyzer $logversion\n";
|
|
|
dc8c34 |
-print "\nCommand: logconv.pl @ARGV\n\n";
|
|
|
dc8c34 |
+print "Access Log Analyzer $logversion\n";
|
|
|
dc8c34 |
+print "Command: logconv.pl @ARGV\n";
|
|
|
dc8c34 |
|
|
|
dc8c34 |
my $rootDNBindCount = 0;
|
|
|
dc8c34 |
my $anonymousBindCount = 0;
|
|
|
dc8c34 |
@@ -414,19 +414,27 @@ for (my $count=0; $count < $file_count; $count++){
|
|
|
dc8c34 |
if($file_count > 1 && $count == 0 && $skipFirstFile == 1){
|
|
|
dc8c34 |
next;
|
|
|
dc8c34 |
}
|
|
|
dc8c34 |
- $linesProcessed = 0; $lineBlockCount = 0;
|
|
|
dc8c34 |
+ if($file_count > 1 && $count == 0 && $skipFirstFile == 1){
|
|
|
dc8c34 |
+ next;
|
|
|
dc8c34 |
+ }
|
|
|
dc8c34 |
+ if (-z $files[$count]){
|
|
|
dc8c34 |
+ # access log is empty
|
|
|
dc8c34 |
+ print "Skipping empty access log ($files[$count])...\n";
|
|
|
dc8c34 |
+ next;
|
|
|
dc8c34 |
+ }
|
|
|
dc8c34 |
+ $linesProcessed = 0; $lineBlockCount = 0;
|
|
|
dc8c34 |
+ my ($dev,$ino,$mode,$nlink,$uid,$gid,$rdev,$atime,$mtime,$ctime,$blksize,$blocks);
|
|
|
dc8c34 |
+ ($dev,$ino,$mode,$nlink,$uid,$gid,$rdev,$cursize,
|
|
|
dc8c34 |
+ $atime,$mtime,$ctime,$blksize,$blocks) = stat($files[$count]);
|
|
|
dc8c34 |
+ print sprintf "[%03d] %-30s\tsize (bytes): %12s\n",$logCount, $files[$count], $cursize;
|
|
|
dc8c34 |
$logCount--;
|
|
|
dc8c34 |
- my $logCountStr;
|
|
|
dc8c34 |
+ my $logCountStr;
|
|
|
dc8c34 |
if($logCount < 10 ){
|
|
|
dc8c34 |
# add a zero for formatting purposes
|
|
|
dc8c34 |
$logCountStr = "0" . $logCount;
|
|
|
dc8c34 |
} else {
|
|
|
dc8c34 |
$logCountStr = $logCount;
|
|
|
dc8c34 |
}
|
|
|
dc8c34 |
- my ($dev,$ino,$mode,$nlink,$uid,$gid,$rdev,$atime,$mtime,$ctime,$blksize,$blocks);
|
|
|
dc8c34 |
- ($dev,$ino,$mode,$nlink,$uid,$gid,$rdev,$cursize,
|
|
|
dc8c34 |
- $atime,$mtime,$ctime,$blksize,$blocks) = stat($files[$count]);
|
|
|
dc8c34 |
- print sprintf "[%s] %-30s\tsize (bytes): %12s\n",$logCountStr, $files[$count], $cursize;
|
|
|
dc8c34 |
|
|
|
dc8c34 |
open(LOG,"$files[$count]") or do { openFailed($!, $files[$count]) };
|
|
|
dc8c34 |
my $firstline = "yes";
|
|
|
dc8c34 |
@@ -452,7 +460,12 @@ for (my $count=0; $count < $file_count; $count++){
|
|
|
dc8c34 |
print_stats_block( $s_stats );
|
|
|
dc8c34 |
print_stats_block( $m_stats );
|
|
|
dc8c34 |
$totalLineCount = $totalLineCount + $linesProcessed;
|
|
|
dc8c34 |
- statusreport();
|
|
|
dc8c34 |
+ statusreport();
|
|
|
dc8c34 |
+}
|
|
|
dc8c34 |
+
|
|
|
dc8c34 |
+if ($totalLineCount eq "0"){
|
|
|
dc8c34 |
+ print "There was no logging to process, exiting...\n";
|
|
|
dc8c34 |
+ exit 1;
|
|
|
dc8c34 |
}
|
|
|
dc8c34 |
|
|
|
dc8c34 |
print "\n\nTotal Log Lines Analysed: " . ($totalLineCount - 1) . "\n";
|
|
|
dc8c34 |
@@ -1366,7 +1379,7 @@ sub displayUsage {
|
|
|
dc8c34 |
|
|
|
dc8c34 |
print "Usage:\n\n";
|
|
|
dc8c34 |
|
|
|
dc8c34 |
- print " ./logconv.pl [-h] [-d|--rootdn <rootDN>] [-s|--sizeLimit <size limit>] [-v|verison] [-Vi|verbose]\n";
|
|
|
dc8c34 |
+ print " ./logconv.pl [-h] [-d|--rootdn <rootDN>] [-s|--sizeLimit <size limit>] [-v|verison] [-V|verbose]\n";
|
|
|
dc8c34 |
print " [-S|--startTime <start time>] [-E|--endTime <end time>] \n";
|
|
|
dc8c34 |
print " [-efcibaltnxrgjuyp] [ access log ... ... ]\n\n";
|
|
|
dc8c34 |
|
|
|
dc8c34 |
@@ -2440,7 +2453,7 @@ removeDataFiles
|
|
|
dc8c34 |
$needCleanup = 0;
|
|
|
dc8c34 |
}
|
|
|
dc8c34 |
|
|
|
dc8c34 |
-END { print "Cleaning up temp files . . .\n"; removeDataFiles(); print "Done\n"; }
|
|
|
dc8c34 |
+END { print "Cleaning up temp files...\n"; removeDataFiles(); print "Done.\n"; }
|
|
|
dc8c34 |
|
|
|
dc8c34 |
sub
|
|
|
dc8c34 |
getIPfromConn
|
|
|
dc8c34 |
--
|
|
|
dc8c34 |
1.8.1.4
|
|
|
dc8c34 |
|