Blame SOURCES/0023-Ticket-47387-improve-logconv.pl-performance-with-lar.patch

ba46c7
From d3d8ec37e369edb8605a2c535f4ce4192c4e5514 Mon Sep 17 00:00:00 2001
ba46c7
From: Rich Megginson <rmeggins@redhat.com>
ba46c7
Date: Mon, 10 Jun 2013 20:04:20 -0600
ba46c7
Subject: [PATCH 23/28] Ticket #47387 - improve logconv.pl performance with large access logs
ba46c7
ba46c7
https://fedorahosted.org/389/ticket/47387
ba46c7
Reviewed by: mreynolds (Thanks!)
ba46c7
Branch: master
ba46c7
Fix Description: The primary fix is to use tied hashes and arrays backed by
ba46c7
DB_File database files.  Hashes use DB_HASH and arrays use DB_RECNO.  These
ba46c7
fixes cut down the time by a factor of 10 or more, and considerably reduce
ba46c7
the size of the disk files.  There is still room for optimization as given
ba46c7
by the Devel::NYTProf package, but this should at least give us acceptable
ba46c7
performance.
ba46c7
I also did some perl "linting" - running with use warnings and use strict -
ba46c7
which revealed a lot of code which was cleaned up.
ba46c7
Platforms tested: RHEL6 x86_64
ba46c7
Flag Day: no
ba46c7
Doc impact: no
ba46c7
(cherry picked from commit 8e35cc8b418bc46fbeb28f4378d24f9c2cab0353)
ba46c7
---
ba46c7
 ldap/admin/src/logconv.pl | 1648 ++++++++++++++++++---------------------------
ba46c7
 1 files changed, 664 insertions(+), 984 deletions(-)
ba46c7
ba46c7
diff --git a/ldap/admin/src/logconv.pl b/ldap/admin/src/logconv.pl
ba46c7
index 8ae72da..b628d03 100755
ba46c7
--- a/ldap/admin/src/logconv.pl
ba46c7
+++ b/ldap/admin/src/logconv.pl
ba46c7
@@ -43,9 +43,14 @@
ba46c7
 #
ba46c7
 # Check for usage
ba46c7
 #
ba46c7
+use strict;
ba46c7
+use warnings;
ba46c7
+use warnings 'untie';
ba46c7
 use Time::Local;
ba46c7
 use IO::File;
ba46c7
 use Getopt::Long;
ba46c7
+use DB_File;
ba46c7
+use sigtrap qw(die normal-signals);
ba46c7
 
ba46c7
 Getopt::Long::Configure ("bundling");
ba46c7
 Getopt::Long::Configure ("permute");
ba46c7
@@ -60,19 +65,43 @@ if ($#ARGV < 0){;
ba46c7
 #                                     #
ba46c7
 #######################################
ba46c7
 
ba46c7
-$file_count = 0;
ba46c7
-$arg_count = 0;
ba46c7
-$logversion = "7.0";
ba46c7
-$sizeCount = "20";
ba46c7
-$startFlag = 0;
ba46c7
-$startTime = 0;
ba46c7
-$endFlag = 0;
ba46c7
-$endTime = 0;
ba46c7
-$reportStats = "";
ba46c7
-$dataLocation = "/tmp";
ba46c7
-$startTLSoid = "1.3.6.1.4.1.1466.20037";
ba46c7
-$s_stats = new_stats_block( );
ba46c7
-$m_stats = new_stats_block( );
ba46c7
+my $file_count = 0;
ba46c7
+my $arg_count = 0;
ba46c7
+my $logversion = "7.0";
ba46c7
+my $sizeCount = "20";
ba46c7
+my $startFlag = 0;
ba46c7
+my $startTime = 0;
ba46c7
+my $endFlag = 0;
ba46c7
+my $endTime = 0;
ba46c7
+my $reportStats = "";
ba46c7
+my $dataLocation = "/tmp";
ba46c7
+my $startTLSoid = "1.3.6.1.4.1.1466.20037";
ba46c7
+my $s_stats = new_stats_block( );
ba46c7
+my $m_stats = new_stats_block( );
ba46c7
+my $verb = "no";
ba46c7
+my @excludeIP;
ba46c7
+my $xi = 0;
ba46c7
+my $bindReportDN;
ba46c7
+my $usage = "";
ba46c7
+my @latency;
ba46c7
+my @openConnection;
ba46c7
+my @errorCode;
ba46c7
+my @errtext;
ba46c7
+my @errornum;
ba46c7
+my @errornum2;
ba46c7
+my $ds6x = "false";
ba46c7
+my $connCodeCount = 0;
ba46c7
+my %connList;
ba46c7
+my %bindReport;
ba46c7
+my @vlvconn;
ba46c7
+my @vlvop;
ba46c7
+my @start_time_of_connection;
ba46c7
+my @end_time_of_connection;
ba46c7
+my @fds;
ba46c7
+my $fdds = 0;
ba46c7
+my $reportBinds = "no";
ba46c7
+my $rootDN = "";
ba46c7
+my $needCleanup = 0;
ba46c7
 
ba46c7
 GetOptions(
ba46c7
 	'd|rootDN=s' => \$rootDN,
ba46c7
@@ -129,6 +158,7 @@ if($rootDN eq ""){
ba46c7
 #
ba46c7
 #  get the logs
ba46c7
 #
ba46c7
+my @files = ();
ba46c7
 while($arg_count <= $#ARGV){
ba46c7
 	$files[$file_count] = $ARGV[$arg_count];
ba46c7
 	$file_count++;
ba46c7
@@ -155,127 +185,93 @@ if ($sizeCount eq "all"){$sizeCount = "100000";}
ba46c7
 print "\nAccess Log Analyzer $logversion\n";
ba46c7
 print "\nCommand: logconv.pl @ARGV\n\n";
ba46c7
 
ba46c7
-$rootDNBindCount = 0;
ba46c7
-$anonymousBindCount = 0;
ba46c7
-$unindexedSrchCountNotesA = 0;
ba46c7
-$unindexedSrchCountNotesU = 0;
ba46c7
-$vlvNotesACount= 0;
ba46c7
-$vlvNotesUCount= 0;
ba46c7
-$srchCount = 0;
ba46c7
-$fdTaken = 0;
ba46c7
-$fdReturned = 0;
ba46c7
-$highestFdTaken = 0;
ba46c7
-$unbindCount = 0;
ba46c7
-$cmpCount = 0;
ba46c7
-$modCount = 0;
ba46c7
-$delCount = 0;
ba46c7
-$addCount = 0;
ba46c7
-$modrdnCount = 0;
ba46c7
-$abandonCount = 0;
ba46c7
-$extopCount = 0;
ba46c7
-$vlvCount = 0;
ba46c7
-$errorCount = 0;
ba46c7
-$proxiedAuthCount = 0;
ba46c7
-$serverRestartCount = 0;
ba46c7
-$resourceUnavailCount = 0;
ba46c7
-$brokenPipeCount = 0;
ba46c7
-$v2BindCount = 0;
ba46c7
-$v3BindCount = 0;
ba46c7
-$vlvSortCount = 0;
ba46c7
-$connResetByPeerCount = 0;
ba46c7
-$isVlvNotes = 0;
ba46c7
-$successCount = 0;
ba46c7
-$sslCount = 0;
ba46c7
-$sslClientBindCount = 0;
ba46c7
-$sslClientFailedCount = 0;
ba46c7
-$objectclassTopCount= 0;
ba46c7
-$pagedSearchCount = 0;
ba46c7
-$bindCount = 0;
ba46c7
-$filterCount = 0;
ba46c7
-$baseCount = 0;
ba46c7
-$scopeCount = 0;
ba46c7
-$allOps = 0;
ba46c7
-$allResults = 0;
ba46c7
-$badPwdCount = 0;
ba46c7
-$saslBindCount = 0;
ba46c7
-$internalOpCount = 0;
ba46c7
-$entryOpCount = 0;
ba46c7
-$referralCount = 0;
ba46c7
-$anyAttrs = 0;
ba46c7
-$persistentSrchCount = 0;
ba46c7
-$maxBerSizeCount = 0;
ba46c7
-$connectionCount = 0;
ba46c7
-$timerange = 0;
ba46c7
-$simConnection = 0;
ba46c7
-$maxsimConnection = 0;
ba46c7
-$firstFile = 1;
ba46c7
-$elapsedDays = 0;
ba46c7
-$logCount = 0;
ba46c7
-$startTLSCount = 0;
ba46c7
-$ldapiCount = 0;
ba46c7
-$autobindCount = 0;
ba46c7
-$limit = 25000; # number of lines processed to trigger output
ba46c7
-
ba46c7
-# hash files
ba46c7
-$ATTR = "$dataLocation/attr.logconv";
ba46c7
-$RC = "$dataLocation/rc.logconv";
ba46c7
-$SRC = "$dataLocation/src.logconv";
ba46c7
-$RSRC = "$dataLocation/rsrc.logconv";
ba46c7
-$EXCOUNT = "$dataLocation/excount.logconv";
ba46c7
-$CONN_HASH = "$dataLocation/conn_hash.logconv";
ba46c7
-$IP_HASH = "$dataLocation/ip_hash.logconv";
ba46c7
-$CONNCOUNT = "$dataLocation/conncount.logconv";
ba46c7
-$NENTRIES = "$dataLocation/nentries.logconv";
ba46c7
-$FILTER = "$dataLocation/filter.logconv";
ba46c7
-$BASE = "$dataLocation/base.logconv";
ba46c7
-$DS6XBADPWD = "$dataLocation/ds6xbadpwd.logconv";
ba46c7
-$SASLMECH = "$dataLocation/saslmech.logconv";
ba46c7
-$BINDLIST = "$dataLocation/bindlist.logconv";
ba46c7
-$ETIME = "$dataLocation/etime.logconv";
ba46c7
-$OID = "$dataLocation/oid.logconv";
ba46c7
-
ba46c7
-# array files
ba46c7
-$SRCH_CONN = "$dataLocation/srchconn.logconv";
ba46c7
-$SRCH_OP = "$dataLocation/srchop.logconv";
ba46c7
-$DEL_CONN = "$dataLocation/delconn.logconv";
ba46c7
-$DEL_OP = "$dataLocation/delop.logconv";
ba46c7
-$MOD_CONN = "$dataLocation/modconn.logconv";
ba46c7
-$MOD_OP = "$dataLocation/modop.logconv";
ba46c7
-$ADD_CONN = "$dataLocation/addconn.logconv";
ba46c7
-$ADD_OP = "$dataLocation/addop.logconv";
ba46c7
-$MODRDN_CONN = "$dataLocation/modrdnconn.logconv";
ba46c7
-$MODRDN_OP = "$dataLocation/modrdnop.logconv";
ba46c7
-$CMP_CONN = "$dataLocation/cmpconn.logconv";
ba46c7
-$CMP_OP = "$dataLocation/cmpop.logconv";
ba46c7
-$TARGET_CONN = "$dataLocation/targetconn.logconv";
ba46c7
-$TARGET_OP = "$dataLocation/targetop.logconv";
ba46c7
-$MSGID = "$dataLocation/msgid.logconv";
ba46c7
-$BIND_CONN = "$dataLocation/bindconn.logconv";
ba46c7
-$BIND_OP = "$dataLocation/bindop.logconv";
ba46c7
-$UNBIND_CONN = "$dataLocation/unbindconn.logconv";
ba46c7
-$UNBIND_OP = "$dataLocation/unbindop.logconv";
ba46c7
-$EXT_CONN = "$dataLocation/extconn.logconv";
ba46c7
-$EXT_OP = "$dataLocation/extop.logconv";
ba46c7
-$NOTES_A_ETIME = "$dataLocation/notesAetime.logconv";
ba46c7
-$NOTES_A_CONN = "$dataLocation/notesAconn.logconv";
ba46c7
-$NOTES_A_OP = "$dataLocation/notesAop.logconv";
ba46c7
-$NOTES_A_TIME = "$dataLocation/notesAtime.logconv";
ba46c7
-$NOTES_A_NENTRIES = "$dataLocation/notesAnentries.logconv";
ba46c7
-$NOTES_U_ETIME = "$dataLocation/notesUetime.logconv";
ba46c7
-$NOTES_U_CONN = "$dataLocation/notesUconn.logconv";
ba46c7
-$NOTES_U_OP = "$dataLocation/notesUop.logconv";
ba46c7
-$NOTES_U_TIME = "$dataLocation/notesUtime.logconv";
ba46c7
-$NOTES_U_NENTRIES = "$dataLocation/notesUnentries.logconv";
ba46c7
-$BADPWDCONN = "$dataLocation/badpwdconn.logconv";
ba46c7
-$BADPWDOP = "$dataLocation/badpwdop.logconv";
ba46c7
-$BADPWDIP = "$dataLocation/badpwdip.logconv";
ba46c7
-
ba46c7
-# info files
ba46c7
-$BINDINFO = "$dataLocation/bindinfo.logconv";
ba46c7
-$BASEINFO = "$dataLocation/baseinfo.logconv";
ba46c7
-$FILTERINFO = "$dataLocation/filterinfo.logconv";
ba46c7
-$SCOPEINFO = "$dataLocation/scopeinfo.logconv";
ba46c7
-
ba46c7
+my $rootDNBindCount = 0;
ba46c7
+my $anonymousBindCount = 0;
ba46c7
+my $unindexedSrchCountNotesA = 0;
ba46c7
+my $unindexedSrchCountNotesU = 0;
ba46c7
+my $vlvNotesACount= 0;
ba46c7
+my $vlvNotesUCount= 0;
ba46c7
+my $srchCount = 0;
ba46c7
+my $fdTaken = 0;
ba46c7
+my $fdReturned = 0;
ba46c7
+my $highestFdTaken = 0;
ba46c7
+my $unbindCount = 0;
ba46c7
+my $cmpCount = 0;
ba46c7
+my $modCount = 0;
ba46c7
+my $delCount = 0;
ba46c7
+my $addCount = 0;
ba46c7
+my $modrdnCount = 0;
ba46c7
+my $abandonCount = 0;
ba46c7
+my $extopCount = 0;
ba46c7
+my $vlvCount = 0;
ba46c7
+my $errorCount = 0;
ba46c7
+my $proxiedAuthCount = 0;
ba46c7
+my $serverRestartCount = 0;
ba46c7
+my $resourceUnavailCount = 0;
ba46c7
+my $brokenPipeCount = 0;
ba46c7
+my $v2BindCount = 0;
ba46c7
+my $v3BindCount = 0;
ba46c7
+my $vlvSortCount = 0;
ba46c7
+my $connResetByPeerCount = 0;
ba46c7
+my $isVlvNotes = 0;
ba46c7
+my $successCount = 0;
ba46c7
+my $sslCount = 0;
ba46c7
+my $sslClientBindCount = 0;
ba46c7
+my $sslClientFailedCount = 0;
ba46c7
+my $objectclassTopCount= 0;
ba46c7
+my $pagedSearchCount = 0;
ba46c7
+my $bindCount = 0;
ba46c7
+my $filterCount = 0;
ba46c7
+my $baseCount = 0;
ba46c7
+my $scopeCount = 0;
ba46c7
+my $allOps = 0;
ba46c7
+my $allResults = 0;
ba46c7
+my $badPwdCount = 0;
ba46c7
+my $saslBindCount = 0;
ba46c7
+my $internalOpCount = 0;
ba46c7
+my $entryOpCount = 0;
ba46c7
+my $referralCount = 0;
ba46c7
+my $anyAttrs = 0;
ba46c7
+my $persistentSrchCount = 0;
ba46c7
+my $maxBerSizeCount = 0;
ba46c7
+my $connectionCount = 0;
ba46c7
+my $timerange = 0;
ba46c7
+my $simConnection = 0;
ba46c7
+my $maxsimConnection = 0;
ba46c7
+my $firstFile = 1;
ba46c7
+my $elapsedDays = 0;
ba46c7
+my $logCount = 0;
ba46c7
+my $startTLSCount = 0;
ba46c7
+my $ldapiCount = 0;
ba46c7
+my $autobindCount = 0;
ba46c7
+my $limit = 25000; # number of lines processed to trigger output
ba46c7
+
ba46c7
+my @removefiles = ();
ba46c7
+
ba46c7
+my @conncodes = qw(A1 B1 B4 T1 T2 B2 B3 R1 P1 P2 U1);
ba46c7
+my %conn = ();
ba46c7
+map {$conn{$_} = $_} @conncodes;
ba46c7
+
ba46c7
+# hash db-backed hashes
ba46c7
+my @hashnames = qw(attr rc src rsrc excount conn_hash ip_hash conncount nentries
ba46c7
+                   filter base ds6xbadpwd saslmech bindlist etime oid);
ba46c7
+# need per connection code ip address counts - so use a hash table
ba46c7
+# for each connection code - key is ip, val is count
ba46c7
+push @hashnames, @conncodes;
ba46c7
+my $hashes = openHashFiles($dataLocation, @hashnames);
ba46c7
+
ba46c7
+# recno db-backed arrays/lists
ba46c7
+my @arraynames = qw(srchconn srchop delconn delop modconn modop addconn addop modrdnconn modrdnop
ba46c7
+                    cmpconn cmpop targetconn targetop msgid bindconn bindop binddn unbindconn unbindop
ba46c7
+                    extconn extop notesAetime notesAconn notesAop notesAtime notesAnentries
ba46c7
+                    notesUetime notesUconn notesUop notesUtime notesUnentries badpwdconn
ba46c7
+                    badpwdop badpwdip baseval baseconn baseop scopeval scopeconn scopeop
ba46c7
+                    filterval filterconn filterop);
ba46c7
+my $arrays = openArrayFiles($dataLocation, @arraynames);
ba46c7
+
ba46c7
+$needCleanup = 1;
ba46c7
+
ba46c7
+my @err;
ba46c7
 $err[0] = "Successful Operations\n";
ba46c7
 $err[1] = "Operations Error(s)\n";
ba46c7
 $err[2] = "Protocal Errors\n";
ba46c7
@@ -338,19 +334,7 @@ $err[95] = "More Results To Return\n";
ba46c7
 $err[96] = "Client Loop\n";
ba46c7
 $err[97] = "Referral Limit Exceeded\n";
ba46c7
 
ba46c7
-
ba46c7
-$conn{"A1"} = "A1";
ba46c7
-$conn{"B1"} = "B1";
ba46c7
-$conn{"B4"} = "B4";
ba46c7
-$conn{"T1"} = "T1";
ba46c7
-$conn{"T2"} = "T2";
ba46c7
-$conn{"B2"} = "B2";
ba46c7
-$conn{"B3"} = "B3";
ba46c7
-$conn{"R1"} = "R1";
ba46c7
-$conn{"P1"} = "P1";
ba46c7
-$conn{"P2"} = "P2";
ba46c7
-$conn{"U1"} = "U1";
ba46c7
-
ba46c7
+my %connmsg;
ba46c7
 $connmsg{"A1"} = "Client Aborted Connections";
ba46c7
 $connmsg{"B1"} = "Bad Ber Tag Encountered";
ba46c7
 $connmsg{"B4"} = "Server failed to flush data (response) back to Client";
ba46c7
@@ -363,7 +347,7 @@ $connmsg{"P1"} = "Plugin";
ba46c7
 $connmsg{"P2"} = "Poll";
ba46c7
 $connmsg{"U1"} = "Cleanly Closed Connections";
ba46c7
 
ba46c7
-%monthname = (
ba46c7
+my %monthname = (
ba46c7
 	"Jan" => 0,
ba46c7
 	"Feb" => 1,
ba46c7
 	"Mar" => 2,
ba46c7
@@ -379,7 +363,17 @@ $connmsg{"U1"} = "Cleanly Closed Connections";
ba46c7
 
ba46c7
 );
ba46c7
 
ba46c7
-openDataFiles();
ba46c7
+my $linesProcessed;
ba46c7
+my $lineBlockCount;
ba46c7
+my $cursize = 0;
ba46c7
+sub statusreport {
ba46c7
+	if ($lineBlockCount > $limit) {
ba46c7
+		my $curpos = tell(LOG);
ba46c7
+		my $percent = $curpos/$cursize*100.0;
ba46c7
+		print sprintf "%10d Lines Processed     %12d of %12d bytes (%.3f%%)\n",--$linesProcessed,$curpos,$cursize,$percent;
ba46c7
+		$lineBlockCount = 0;
ba46c7
+	}
ba46c7
+}
ba46c7
 
ba46c7
 ##########################################
ba46c7
 #                                        #
ba46c7
@@ -394,6 +388,7 @@ print "Processing $file_count Access Log(s)...\n\n";
ba46c7
 #print "Filename\t\t\t   Total Lines\n";
ba46c7
 #print "--------------------------------------------------\n";
ba46c7
 
ba46c7
+my $skipFirstFile = 0;
ba46c7
 if ($file_count > 1 && $files[0] =~ /\/access$/){
ba46c7
         $files[$file_count] = $files[0];
ba46c7
         $file_count++;
ba46c7
@@ -401,25 +396,30 @@ if ($file_count > 1 && $files[0] =~ /\/access$/){
ba46c7
 }
ba46c7
 $logCount = $file_count;
ba46c7
 
ba46c7
-for ($count=0; $count < $file_count; $count++){
ba46c7
+my $logline;
ba46c7
+my $totalLineCount = 0;
ba46c7
+
ba46c7
+for (my $count=0; $count < $file_count; $count++){
ba46c7
 	# we moved access to the end of the list, so if its the first file skip it
ba46c7
         if($file_count > 1 && $count == 0 && $skipFirstFile == 1){
ba46c7
                 next;
ba46c7
         }
ba46c7
-        $logsize = `wc -l $files[$count]`;
ba46c7
-        $logsize =~ /([0-9]+)/;
ba46c7
         $linesProcessed = 0; $lineBlockCount = 0;
ba46c7
 	$logCount--;
ba46c7
+		my $logCountStr;
ba46c7
 	if($logCount < 10 ){ 
ba46c7
 		# add a zero for formatting purposes
ba46c7
 		$logCountStr = "0" . $logCount;
ba46c7
 	} else {
ba46c7
 		$logCountStr = $logCount;
ba46c7
 	}
ba46c7
-	print sprintf "[%s] %-30s\tlines: %7s\n",$logCountStr, $files[$count], $1;
ba46c7
+		my ($dev,$ino,$mode,$nlink,$uid,$gid,$rdev,$atime,$mtime,$ctime,$blksize,$blocks);
ba46c7
+		($dev,$ino,$mode,$nlink,$uid,$gid,$rdev,$cursize,
ba46c7
+		 $atime,$mtime,$ctime,$blksize,$blocks) = stat($files[$count]);
ba46c7
+		print sprintf "[%s] %-30s\tsize (bytes): %12s\n",$logCountStr, $files[$count], $cursize;
ba46c7
 	
ba46c7
 	open(LOG,"$files[$count]") or do { openFailed($!, $files[$count]) };
ba46c7
-	$firstline = "yes";
ba46c7
+	my $firstline = "yes";
ba46c7
 	while(<LOG>){
ba46c7
 		unless ($endFlag) {
ba46c7
 			if ($firstline eq "yes"){
ba46c7
@@ -442,7 +442,7 @@ for ($count=0; $count < $file_count; $count++){
ba46c7
 	print_stats_block( $s_stats );
ba46c7
 	print_stats_block( $m_stats );
ba46c7
 	$totalLineCount = $totalLineCount + $linesProcessed;
ba46c7
-	if($linesProcessed => $limit){print sprintf " %10s Lines Processed\n\n",--$linesProcessed;}
ba46c7
+		statusreport();
ba46c7
 }
ba46c7
 
ba46c7
 print "\n\nTotal Log Lines Analysed:  " . ($totalLineCount - 1) . "\n";
ba46c7
@@ -457,9 +457,11 @@ $allOps = $srchCount + $modCount + $addCount + $cmpCount + $delCount + $modrdnCo
ba46c7
 
ba46c7
 # if we are using startTime & endTime then we need to clean it up for our processing
ba46c7
 
ba46c7
+my $start;
ba46c7
 if($startTime){
ba46c7
 	if ($start =~ / *([0-9a-z:\/]+)/i){$start=$1;}
ba46c7
 }
ba46c7
+my $end;
ba46c7
 if($endTime){
ba46c7
 	if ($end =~ / *([0-9a-z:\/]+)/i){$end =$1;}
ba46c7
 }
ba46c7
@@ -468,8 +470,10 @@ if($endTime){
ba46c7
 # Get the start time in seconds
ba46c7
 #  
ba46c7
 
ba46c7
-$logStart = $start;
ba46c7
-
ba46c7
+my $logStart = $start;
ba46c7
+my $logDate;
ba46c7
+my @dateComps;
ba46c7
+my ($timeMonth, $timeDay, $timeYear, $dateTotal);
ba46c7
 if ($logStart =~ / *([0-9A-Z\/]+)/i ){
ba46c7
         $logDate = $1;
ba46c7
         @dateComps = split /\//, $logDate;
ba46c7
@@ -481,6 +485,9 @@ if ($logStart =~ / *([0-9A-Z\/]+)/i ){
ba46c7
         $dateTotal = $timeMonth + $timeDay + $timeYear;
ba46c7
 }
ba46c7
 
ba46c7
+my $logTime;
ba46c7
+my @timeComps;
ba46c7
+my ($timeHour, $timeMinute, $timeSecond, $timeTotal);
ba46c7
 if ($logStart =~ / *(:[0-9:]+)/i ){
ba46c7
         $logTime = $1;
ba46c7
         @timeComps = split /:/, $logTime;
ba46c7
@@ -491,14 +498,14 @@ if ($logStart =~ / *(:[0-9:]+)/i ){
ba46c7
         $timeTotal = $timeHour + $timeMinute + $timeSecond;
ba46c7
 }
ba46c7
 
ba46c7
-$startTotal = $timeTotal + $dateTotal;
ba46c7
+my $startTotal = $timeTotal + $dateTotal;
ba46c7
 
ba46c7
 #
ba46c7
 # Get the end time in seconds
ba46c7
 #
ba46c7
 
ba46c7
-$logEnd = $end;
ba46c7
-
ba46c7
+my $logEnd = $end;
ba46c7
+my ($endDay, $endMonth, $endYear, $endTotal);
ba46c7
 if ($logEnd =~ / *([0-9A-Z\/]+)/i ){
ba46c7
         $logDate = $1;
ba46c7
         @dateComps = split /\//, $logDate;
ba46c7
@@ -506,10 +513,11 @@ if ($logEnd =~ / *([0-9A-Z\/]+)/i ){
ba46c7
         $endDay = $dateComps[0] *3600 * 24;
ba46c7
         $endMonth = 1 + $monthname{$dateComps[1]};
ba46c7
         $endMonth = $endMonth * 3600 * 24 * 30;
ba46c7
-        $endYear = $endTotal + $dateComps[2] *365 * 3600 * 24 ;
ba46c7
+        $endYear = $dateComps[2] *365 * 3600 * 24 ;
ba46c7
         $dateTotal = $endDay + $endMonth + $endYear;
ba46c7
 }
ba46c7
 
ba46c7
+my ($endHour, $endMinute, $endSecond);
ba46c7
 if ($logEnd =~ / *(:[0-9:]+)/i ){
ba46c7
         $logTime = $1;
ba46c7
         @timeComps = split /:/, $logTime;
ba46c7
@@ -525,8 +533,8 @@ $endTotal = $timeTotal +  $dateTotal;
ba46c7
 #
ba46c7
 # Tally the numbers
ba46c7
 #
ba46c7
-$totalTimeInSecs = $endTotal - $startTotal;
ba46c7
-$remainingTimeInSecs = $totalTimeInSecs;
ba46c7
+my $totalTimeInSecs = $endTotal - $startTotal;
ba46c7
+my $remainingTimeInSecs = $totalTimeInSecs;
ba46c7
 
ba46c7
 #
ba46c7
 # Calculate the elapsed time
ba46c7
@@ -540,33 +548,21 @@ while(($remainingTimeInSecs - 86400) > 0){
ba46c7
 }
ba46c7
 
ba46c7
 # hours
ba46c7
+my $elapsedHours = 0;
ba46c7
 while(($remainingTimeInSecs - 3600) > 0){
ba46c7
 	$elapsedHours++;
ba46c7
 	$remainingTimeInSecs = $remainingTimeInSecs - 3600;
ba46c7
 }
ba46c7
 
ba46c7
 # minutes
ba46c7
+my $elapsedMinutes = 0;
ba46c7
 while($remainingTimeInSecs - 60 > 0){
ba46c7
 	$elapsedMinutes++;
ba46c7
 	$remainingTimeInSecs = $remainingTimeInSecs - 60;
ba46c7
 }
ba46c7
 
ba46c7
 # seconds
ba46c7
-$elapsedSeconds = $remainingTimeInSecs;
ba46c7
-
ba46c7
-# Initialize empty values
ba46c7
-if($elapsedHours eq ""){
ba46c7
-	$elapsedHours = "0";
ba46c7
-}
ba46c7
-if($elapsedMinutes eq ""){
ba46c7
-	$elapsedMinutes = "0";
ba46c7
-}
ba46c7
-if($elapsedSeconds eq ""){
ba46c7
-	$elapsedSeconds = "0";
ba46c7
-}
ba46c7
-
ba46c7
-&closeDataFiles();
ba46c7
-
ba46c7
+my $elapsedSeconds = $remainingTimeInSecs;
ba46c7
 
ba46c7
 #####################################
ba46c7
 #                                   #
ba46c7
@@ -605,20 +601,21 @@ print " - LDAPI Connections:         $ldapiCount\n";
ba46c7
 print "Peak Concurrent Connections:  $maxsimConnection\n";
ba46c7
 print "Total Operations:             $allOps\n";
ba46c7
 print "Total Results:                $allResults\n";
ba46c7
+my ($perf, $tmp);
ba46c7
 if ($allOps ne "0"){
ba46c7
- print sprintf "Overall Performance:          %.1f%\n\n" , ($perf = ($tmp = ($allResults / $allOps)*100) > 100 ? 100.0 : $tmp) ;
ba46c7
+ print sprintf "Overall Performance:          %.1f%%\n\n" , ($perf = ($tmp = ($allResults / $allOps)*100) > 100 ? 100.0 : $tmp) ;
ba46c7
  }
ba46c7
 else {
ba46c7
  print "Overall Performance:          No Operations to evaluate\n\n";
ba46c7
 }
ba46c7
 
ba46c7
-$searchStat = sprintf "(%.2f/sec)  (%.2f/min)\n",($srchCount / $totalTimeInSecs), $srchCount / ($totalTimeInSecs/60);
ba46c7
-$modStat = sprintf "(%.2f/sec)  (%.2f/min)\n",$modCount / $totalTimeInSecs, $modCount/($totalTimeInSecs/60);
ba46c7
-$addStat = sprintf "(%.2f/sec)  (%.2f/min)\n",$addCount/$totalTimeInSecs, $addCount/($totalTimeInSecs/60);
ba46c7
-$deleteStat = sprintf "(%.2f/sec)  (%.2f/min)\n",$delCount/$totalTimeInSecs, $delCount/($totalTimeInSecs/60);
ba46c7
-$modrdnStat = sprintf "(%.2f/sec)  (%.2f/min)\n",$modrdnCount/$totalTimeInSecs, $modrdnCount/($totalTimeInSecs/60);
ba46c7
-$compareStat = sprintf "(%.2f/sec)  (%.2f/min)\n",$cmpCount/$totalTimeInSecs, $cmpCount/($totalTimeInSecs/60);
ba46c7
-$bindCountStat = sprintf "(%.2f/sec)  (%.2f/min)\n",$bindCount/$totalTimeInSecs, $bindCount/($totalTimeInSecs/60);
ba46c7
+my $searchStat = sprintf "(%.2f/sec)  (%.2f/min)\n",($srchCount / $totalTimeInSecs), $srchCount / ($totalTimeInSecs/60);
ba46c7
+my $modStat = sprintf "(%.2f/sec)  (%.2f/min)\n",$modCount / $totalTimeInSecs, $modCount/($totalTimeInSecs/60);
ba46c7
+my $addStat = sprintf "(%.2f/sec)  (%.2f/min)\n",$addCount/$totalTimeInSecs, $addCount/($totalTimeInSecs/60);
ba46c7
+my $deleteStat = sprintf "(%.2f/sec)  (%.2f/min)\n",$delCount/$totalTimeInSecs, $delCount/($totalTimeInSecs/60);
ba46c7
+my $modrdnStat = sprintf "(%.2f/sec)  (%.2f/min)\n",$modrdnCount/$totalTimeInSecs, $modrdnCount/($totalTimeInSecs/60);
ba46c7
+my $compareStat = sprintf "(%.2f/sec)  (%.2f/min)\n",$cmpCount/$totalTimeInSecs, $cmpCount/($totalTimeInSecs/60);
ba46c7
+my $bindCountStat = sprintf "(%.2f/sec)  (%.2f/min)\n",$bindCount/$totalTimeInSecs, $bindCount/($totalTimeInSecs/60);
ba46c7
 
ba46c7
 format STDOUT =
ba46c7
 Searches:                     @<<<<<<<<<<<< @<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
ba46c7
@@ -658,148 +655,110 @@ print "Unindexed Searches:           $unindexedSrchCountNotesA\n";
ba46c7
 print "Unindexed Components:         $unindexedSrchCountNotesU\n";
ba46c7
 if ($verb eq "yes" || $usage =~ /u/){
ba46c7
 	if ($unindexedSrchCountNotesA > 0){
ba46c7
-		%conn_hash = getHashFromFile($CONN_HASH);
ba46c7
-		@notesConn = getArrayFromFile($NOTES_A_CONN);
ba46c7
-		@notesOp = getArrayFromFile($NOTES_A_OP);
ba46c7
-		@notesEtime = getArrayFromFile($NOTES_A_ETIME);
ba46c7
-		@notesTime = getArrayFromFile($NOTES_A_TIME);
ba46c7
-		@notesNentries = getArrayFromFile($NOTES_A_NENTRIES);
ba46c7
-		getInfoArraysFromFile($BASEINFO);
ba46c7
-		@base_val = @fileArray1;
ba46c7
-		@base_conn = @fileArray2;
ba46c7
-		@base_op = @fileArray3;
ba46c7
-		getInfoArraysFromFile($SCOPEINFO);
ba46c7
-		@scope_val = @fileArray1;
ba46c7
-		@scope_conn = @fileArray2;
ba46c7
-		@scope_op = @fileArray3;
ba46c7
-		getInfoArraysFromFile($FILTERINFO);
ba46c7
-		@filter_val = @fileArray1;
ba46c7
-		@filter_conn = @fileArray2;
ba46c7
-		@filter_op = @fileArray3;
ba46c7
-
ba46c7
-		$notesCount = "1";
ba46c7
-		for ($n = 0; $n <= $#notesEtime; $n++){
ba46c7
-			@alreadyseenDN = ();
ba46c7
-			if($conn_hash{$notesConn[$n]} eq ""){
ba46c7
+		my $conn_hash = $hashes->{conn_hash};
ba46c7
+		my $notesConn = $arrays->{notesAconn};
ba46c7
+		my $notesOp = $arrays->{notesAop};
ba46c7
+		my $notesEtime = $arrays->{notesAetime};
ba46c7
+		my $notesTime = $arrays->{notesAtime};
ba46c7
+		my $notesNentries = $arrays->{notesAnentries};
ba46c7
+		my $base_val = $arrays->{baseval};
ba46c7
+		my $base_conn = $arrays->{baseconn};
ba46c7
+		my $base_op = $arrays->{baseop};
ba46c7
+		my $scope_val = $arrays->{scopeval};
ba46c7
+		my $scope_conn = $arrays->{scopeconn};
ba46c7
+		my $scope_op = $arrays->{scopeop};
ba46c7
+		my $filter_val = $arrays->{filterval};
ba46c7
+		my $filter_conn = $arrays->{filterconn};
ba46c7
+		my $filter_op = $arrays->{filterop};
ba46c7
+
ba46c7
+		my $notesCount = "1";
ba46c7
+		my $unindexedIp;
ba46c7
+		for (my $n = 0; $n <= scalar(@{$notesEtime}); $n++){
ba46c7
+			if($conn_hash->{$notesConn->[$n]} eq ""){
ba46c7
 				$unindexedIp = "?";
ba46c7
 			} else {
ba46c7
-				$unindexedIp = $conn_hash{$notesConn[$n]};
ba46c7
+				$unindexedIp = $conn_hash->{$notesConn->[$n]};
ba46c7
 			}
ba46c7
 			print "\n  Unindexed Search #".$notesCount."\n"; $notesCount++;
ba46c7
-			print "  -  Date/Time:             $notesTime[$n]\n";
ba46c7
-			print "  -  Connection Number:     $notesConn[$n]\n";
ba46c7
-			print "  -  Operation Number:      $notesOp[$n]\n";
ba46c7
-			print "  -  Etime:                 $notesEtime[$n]\n";
ba46c7
-			print "  -  Nentries:              $notesNentries[$n]\n";
ba46c7
+			print "  -  Date/Time:             $notesTime->[$n]\n";
ba46c7
+			print "  -  Connection Number:     $notesConn->[$n]\n";
ba46c7
+			print "  -  Operation Number:      $notesOp->[$n]\n";
ba46c7
+			print "  -  Etime:                 $notesEtime->[$n]\n";
ba46c7
+			print "  -  Nentries:              $notesNentries->[$n]\n";
ba46c7
 			print "  -  IP Address:            $unindexedIp\n";
ba46c7
 
ba46c7
-			for ($nnn = 0; $nnn < $baseCount; $nnn++){
ba46c7
-				if ($notesConn[$n] eq $base_conn[$nnn] && $notesOp[$n] eq $base_op[$nnn]){
ba46c7
-					print "  -  Search Base:           $base_val[$nnn]\n";
ba46c7
+			for (my $nnn = 0; $nnn < $baseCount; $nnn++){
ba46c7
+				if ($notesConn->[$n] eq $base_conn->[$nnn] && $notesOp->[$n] eq $base_op->[$nnn]){
ba46c7
+					print "  -  Search Base:           $base_val->[$nnn]\n";
ba46c7
 					last;
ba46c7
 				}
ba46c7
 			}
ba46c7
-			for ($nnn = 0; $nnn < $scopeCount; $nnn++){
ba46c7
-				if ($notesConn[$n] eq $scope_conn[$nnn] && $notesOp[$n] eq $scope_op[$nnn]){
ba46c7
-					print "  -  Search Scope:          $scope_val[$nnn]\n";
ba46c7
+			for (my $nnn = 0; $nnn < $scopeCount; $nnn++){
ba46c7
+				if ($notesConn->[$n] eq $scope_conn->[$nnn] && $notesOp->[$n] eq $scope_op->[$nnn]){
ba46c7
+					print "  -  Search Scope:          $scope_val->[$nnn]\n";
ba46c7
 					last;
ba46c7
 				}
ba46c7
 			}
ba46c7
-			for ($nnn = 0; $nnn < $filterCount; $nnn++){	
ba46c7
-				if ($notesConn[$n] eq $filter_conn[$nnn] && $notesOp[$n] eq $filter_op[$nnn]){
ba46c7
-					print "  -  Search Filter:         $filter_val[$nnn]\n";
ba46c7
+			for (my $nnn = 0; $nnn < $filterCount; $nnn++){	
ba46c7
+				if ($notesConn->[$n] eq $filter_conn->[$nnn] && $notesOp->[$n] eq $filter_op->[$nnn]){
ba46c7
+					print "  -  Search Filter:         $filter_val->[$nnn]\n";
ba46c7
 					last;
ba46c7
 				}	
ba46c7
 			}
ba46c7
 		}
ba46c7
-		undef %conn_hash;
ba46c7
-		undef @notesConn;
ba46c7
-		undef @notesOp;
ba46c7
-		undef @notesEtime;
ba46c7
-		undef @notesTime;
ba46c7
-		undef @notesNentries;
ba46c7
-		undef @notesIp;
ba46c7
-		undef @filter_val;
ba46c7
-		undef @filter_conn;
ba46c7
-		undef @filter_op;
ba46c7
-		undef @base_val;
ba46c7
-		undef @base_conn;
ba46c7
-		undef @base_op;
ba46c7
-		undef @scope_val;
ba46c7
-		undef @scope_conn;
ba46c7
-		undef @scope_op;	
ba46c7
 	}
ba46c7
 	if ($unindexedSrchCountNotesU > 0){
ba46c7
-		%conn_hash = getHashFromFile($CONN_HASH);
ba46c7
-		@notesConn = getArrayFromFile($NOTES_U_CONN);
ba46c7
-		@notesOp = getArrayFromFile($NOTES_U_OP);
ba46c7
-		@notesEtime = getArrayFromFile($NOTES_U_ETIME);
ba46c7
-		@notesTime = getArrayFromFile($NOTES_U_TIME);
ba46c7
-		@notesNentries = getArrayFromFile($NOTES_U_NENTRIES);
ba46c7
-		getInfoArraysFromFile($BASEINFO);
ba46c7
-		@base_val = @fileArray1;
ba46c7
-		@base_conn = @fileArray2;
ba46c7
-		@base_op = @fileArray3;
ba46c7
-		getInfoArraysFromFile($SCOPEINFO);
ba46c7
-		@scope_val = @fileArray1;
ba46c7
-		@scope_conn = @fileArray2;
ba46c7
-		@scope_op = @fileArray3;
ba46c7
-		getInfoArraysFromFile($FILTERINFO);
ba46c7
-		@filter_val = @fileArray1;
ba46c7
-		@filter_conn = @fileArray2;
ba46c7
-		@filter_op = @fileArray3;
ba46c7
-
ba46c7
-		$notesCount = "1";
ba46c7
-		for ($n = 0; $n <= $#notesEtime; $n++){
ba46c7
-			@alreadyseenDN = ();
ba46c7
-			if($conn_hash{$notesConn[$n]} eq ""){
ba46c7
+		my $conn_hash = $hashes->{conn_hash};
ba46c7
+		my $notesConn = $arrays->{notesUconn};
ba46c7
+		my $notesOp = $arrays->{notesUop};
ba46c7
+		my $notesEtime = $arrays->{notesUetime};
ba46c7
+		my $notesTime = $arrays->{notesUtime};
ba46c7
+		my $notesNentries = $arrays->{notesUnentries};
ba46c7
+		my $base_val = $arrays->{baseval};
ba46c7
+		my $base_conn = $arrays->{baseconn};
ba46c7
+		my $base_op = $arrays->{baseop};
ba46c7
+		my $scope_val = $arrays->{scopeval};
ba46c7
+		my $scope_conn = $arrays->{scopeconn};
ba46c7
+		my $scope_op = $arrays->{scopeop};
ba46c7
+		my $filter_val = $arrays->{filterval};
ba46c7
+		my $filter_conn = $arrays->{filterconn};
ba46c7
+		my $filter_op = $arrays->{filterop};
ba46c7
+
ba46c7
+		my $notesCount = "1";
ba46c7
+		my $unindexedIp;
ba46c7
+		for (my $n = 0; $n <= scalar(@{$notesEtime}); $n++){
ba46c7
+			if($conn_hash->{$notesConn->[$n]} eq ""){
ba46c7
 				$unindexedIp = "?";
ba46c7
 			} else {
ba46c7
-				$unindexedIp = $conn_hash{$notesConn[$n]};
ba46c7
+				$unindexedIp = $conn_hash->{$notesConn->[$n]};
ba46c7
 			}
ba46c7
 			print "\n  Unindexed Components #".$notesCount."\n"; $notesCount++;
ba46c7
-			print "  -  Date/Time:             $notesTime[$n]\n";
ba46c7
-			print "  -  Connection Number:     $notesConn[$n]\n";
ba46c7
-			print "  -  Operation Number:      $notesOp[$n]\n";
ba46c7
-			print "  -  Etime:                 $notesEtime[$n]\n";
ba46c7
-			print "  -  Nentries:              $notesNentries[$n]\n";
ba46c7
+			print "  -  Date/Time:             $notesTime->[$n]\n";
ba46c7
+			print "  -  Connection Number:     $notesConn->[$n]\n";
ba46c7
+			print "  -  Operation Number:      $notesOp->[$n]\n";
ba46c7
+			print "  -  Etime:                 $notesEtime->[$n]\n";
ba46c7
+			print "  -  Nentries:              $notesNentries->[$n]\n";
ba46c7
 			print "  -  IP Address:            $unindexedIp\n";
ba46c7
 
ba46c7
-			for ($nnn = 0; $nnn < $baseCount; $nnn++){
ba46c7
-				if ($notesConn[$n] eq $base_conn[$nnn] && $notesOp[$n] eq $base_op[$nnn]){
ba46c7
-					print "  -  Search Base:           $base_val[$nnn]\n";
ba46c7
+			for (my $nnn = 0; $nnn < $baseCount; $nnn++){
ba46c7
+				if ($notesConn->[$n] eq $base_conn->[$nnn] && $notesOp->[$n] eq $base_op->[$nnn]){
ba46c7
+					print "  -  Search Base:           $base_val->[$nnn]\n";
ba46c7
 					last;
ba46c7
 				}
ba46c7
 			}
ba46c7
-			for ($nnn = 0; $nnn < $scopeCount; $nnn++){
ba46c7
-				if ($notesConn[$n] eq $scope_conn[$nnn] && $notesOp[$n] eq $scope_op[$nnn]){
ba46c7
-					print "  -  Search Scope:          $scope_val[$nnn]\n";
ba46c7
+			for (my $nnn = 0; $nnn < $scopeCount; $nnn++){
ba46c7
+				if ($notesConn->[$n] eq $scope_conn->[$nnn] && $notesOp->[$n] eq $scope_op->[$nnn]){
ba46c7
+					print "  -  Search Scope:          $scope_val->[$nnn]\n";
ba46c7
 					last;
ba46c7
 				}
ba46c7
 			}
ba46c7
-			for ($nnn = 0; $nnn < $filterCount; $nnn++){	
ba46c7
-				if ($notesConn[$n] eq $filter_conn[$nnn] && $notesOp[$n] eq $filter_op[$nnn]){
ba46c7
-					print "  -  Search Filter:         $filter_val[$nnn]\n";
ba46c7
+			for (my $nnn = 0; $nnn < $filterCount; $nnn++){	
ba46c7
+				if ($notesConn->[$n] eq $filter_conn->[$nnn] && $notesOp->[$n] eq $filter_op->[$nnn]){
ba46c7
+					print "  -  Search Filter:         $filter_val->[$nnn]\n";
ba46c7
 					last;
ba46c7
 				}	
ba46c7
 			}
ba46c7
 		}
ba46c7
-		undef %conn_hash;
ba46c7
-		undef @notesConn;
ba46c7
-		undef @notesOp;
ba46c7
-		undef @notesEtime;
ba46c7
-		undef @notesTime;
ba46c7
-		undef @notesNentries;
ba46c7
-		undef @notesIp;
ba46c7
-		undef @filter_val;
ba46c7
-		undef @filter_conn;
ba46c7
-		undef @filter_op;
ba46c7
-		undef @base_val;
ba46c7
-		undef @base_conn;
ba46c7
-		undef @base_op;
ba46c7
-		undef @scope_val;
ba46c7
-		undef @scope_conn;
ba46c7
-		undef @scope_op;	
ba46c7
 	}
ba46c7
 } # end of unindexed search report
ba46c7
 
ba46c7
@@ -809,10 +768,12 @@ print "FDs Returned:                 $fdReturned\n";
ba46c7
 print "Highest FD Taken:             $highestFdTaken\n\n";
ba46c7
 print "Broken Pipes:                 $brokenPipeCount\n";
ba46c7
 if ($brokenPipeCount > 0){
ba46c7
-	foreach $key (sort { $rc{$b} <=> $rc{$a} } keys %rc) {
ba46c7
-          if ($rc{$key} > 0){
ba46c7
+	my $rc = $hashes->{rc};
ba46c7
+	my @etext;
ba46c7
+	foreach my $key (sort { $rc->{$b} <=> $rc->{$a} } keys %{$rc}) {
ba46c7
+		if ($rc->{$key} > 0){
ba46c7
            if ($conn{$key} eq ""){$conn{$key} = "**Unknown**";}
ba46c7
-           push @etext, sprintf "     -  %-4s (%2s) %-40s\n",$rc{$key},$conn{$key},$connmsg{$key
ba46c7
+           push @etext, sprintf "     -  %-4s (%2s) %-40s\n",$rc->{$key},$conn{$key},$connmsg{$key
ba46c7
 };
ba46c7
           }
ba46c7
         }
ba46c7
@@ -822,10 +783,12 @@ if ($brokenPipeCount > 0){
ba46c7
 
ba46c7
 print "Connections Reset By Peer:    $connResetByPeerCount\n";
ba46c7
 if ($connResetByPeerCount > 0){
ba46c7
-	foreach $key (sort { $src{$b} <=> $src{$a} } keys %src) {
ba46c7
-          if ($src{$key} > 0){
ba46c7
+	my $src = $hashes->{src};
ba46c7
+	my @retext;
ba46c7
+	foreach my $key (sort { $src->{$b} <=> $src->{$a} } keys %{$src}) {
ba46c7
+		if ($src->{$key} > 0){
ba46c7
            if ($conn{$key} eq ""){$conn{$key} = "**Unknown**";}
ba46c7
-           push @retext, sprintf "     -  %-4s (%2s) %-40s\n",$src{$key},$conn{$key},$connmsg{$key
ba46c7
+           push @retext, sprintf "     -  %-4s (%2s) %-40s\n",$src->{$key},$conn{$key},$connmsg{$key
ba46c7
 };
ba46c7
           }
ba46c7
         }
ba46c7
@@ -835,10 +798,12 @@ if ($connResetByPeerCount > 0){
ba46c7
 
ba46c7
 print "Resource Unavailable:         $resourceUnavailCount\n";
ba46c7
 if ($resourceUnavailCount > 0){
ba46c7
-	foreach $key (sort { $rsrc{$b} <=> $rsrc{$a} } keys %rsrc) {
ba46c7
-          if ($rsrc{$key} > 0){
ba46c7
+	my $rsrc = $hashes->{rsrc};
ba46c7
+	my @rtext;
ba46c7
+	foreach my $key (sort { $rsrc->{$b} <=> $rsrc->{$a} } keys %{$rsrc}) {
ba46c7
+		if ($rsrc->{$key} > 0){
ba46c7
            if ($conn{$key} eq ""){$conn{$key} = "**Resource Issue**";}
ba46c7
-           push @rtext, sprintf "     -  %-4s (%2s) %-40s\n",$rsrc{$key},$conn{$key},$connmsg{$key};
ba46c7
+           push @rtext, sprintf "     -  %-4s (%2s) %-40s\n",$rsrc->{$key},$conn{$key},$connmsg{$key};
ba46c7
           }
ba46c7
   	}
ba46c7
   	print @rtext;
ba46c7
@@ -854,14 +819,15 @@ print " - SSL Client Binds:          $sslClientBindCount\n";
ba46c7
 print " - Failed SSL Client Binds:   $sslClientFailedCount\n";
ba46c7
 print " - SASL Binds:                $saslBindCount\n";
ba46c7
 if ($saslBindCount > 0){
ba46c7
- foreach $saslb ( sort {$saslmech{$b} <=> $saslmech{$a} } (keys %saslmech) ){
ba46c7
-	printf "    %-4s  %-12s\n",$saslmech{$saslb}, $saslb;   
ba46c7
- }
ba46c7
+	my $saslmech = $hashes->{saslmech};
ba46c7
+	foreach my $saslb ( sort {$saslmech->{$b} <=> $saslmech->{$a} } (keys %{$saslmech}) ){
ba46c7
+		printf "    %-4s  %-12s\n",$saslmech->{$saslb}, $saslb;   
ba46c7
+	}
ba46c7
 }
ba46c7
 
ba46c7
 print " - Directory Manager Binds:   $rootDNBindCount\n";
ba46c7
 print " - Anonymous Binds:           $anonymousBindCount\n";
ba46c7
-$otherBindCount = $bindCount -($rootDNBindCount + $anonymousBindCount);
ba46c7
+my $otherBindCount = $bindCount -($rootDNBindCount + $anonymousBindCount);
ba46c7
 print " - Other Binds:               $otherBindCount\n\n";
ba46c7
 
ba46c7
 ##########################################################################
ba46c7
@@ -879,8 +845,10 @@ if ($verb eq "yes" || $usage =~ /y/){
ba46c7
 	print " (in seconds)\t\t<=1\t2\t3\t4-5\t6-10\t11-15\t>15\n";
ba46c7
 	print " --------------------------------------------------------------------------\n";
ba46c7
 	print " (# of connections)\t";
ba46c7
-	for ($i=0; $i <=$#latency; $i++) {
ba46c7
-		print "$latency[$i]\t";
ba46c7
+	for (my $i=0; $i <=$#latency; $i++) {
ba46c7
+		if (defined($latency[$i])) {
ba46c7
+			print "$latency[$i]\t";
ba46c7
+		}
ba46c7
 	}
ba46c7
 }
ba46c7
 
ba46c7
@@ -891,9 +859,9 @@ if ($verb eq "yes" || $usage =~ /y/){
ba46c7
 ###################################
ba46c7
 
ba46c7
 if ($verb eq "yes" || $usage =~ /p/){
ba46c7
-	if ($openConnection[0] ne ""){
ba46c7
+	if (@openConnection > 0){
ba46c7
 		print "\n\n----- Current Open Connection IDs ----- \n\n";
ba46c7
-		for ($i=0; $i <= $#openConnection ; $i++) {
ba46c7
+		for (my $i=0; $i <= $#openConnection ; $i++) {
ba46c7
 			if ($openConnection[$i]) {
ba46c7
 				print "Conn Number:  $i (" . getIPfromConn($i) . ")\n";
ba46c7
 			}
ba46c7
@@ -910,17 +878,16 @@ if ($verb eq "yes" || $usage =~ /p/){
ba46c7
 if ($usage =~ /e/i || $verb eq "yes"){
ba46c7
 	print "\n\n----- Errors -----\n";
ba46c7
 
ba46c7
-	%er = sort( {$b <=> $a} %er);
ba46c7
-	for ($i = 0; $i<98; $i++){
ba46c7
-		if ($err[$i] ne "" && $errorCode[$i] >0) {
ba46c7
+	for (my $i = 0; $i<98; $i++){
ba46c7
+		if (defined($err[$i]) && $err[$i] ne "" && defined($errorCode[$i]) && $errorCode[$i] >0) {
ba46c7
 			push @errtext, sprintf "%-8s       %12s    %-25s","err=$i",$errorCode[$i],$err[$i];
ba46c7
 		}
ba46c7
 	}
ba46c7
 
ba46c7
-	for ($i = 0; $i < $#errtext; $i++){
ba46c7
-		for ($ii = 0; $ii < $#errtext; $ii++){
ba46c7
-			$yy="0";
ba46c7
-			$zz="0";
ba46c7
+	for (my $i = 0; $i < $#errtext; $i++){
ba46c7
+		for (my $ii = 0; $ii < $#errtext; $ii++){
ba46c7
+			my $yy="0";
ba46c7
+			my $zz="0";
ba46c7
 			while ($errtext[$ii] =~ /(\w+)\s/g){
ba46c7
 				$errornum[$yy]="$1";
ba46c7
 				$yy++;
ba46c7
@@ -936,7 +903,7 @@ if ($usage =~ /e/i || $verb eq "yes"){
ba46c7
 			}
ba46c7
 		}
ba46c7
 	}
ba46c7
-	for ($i = 0; $i <= $#errtext; $i++){
ba46c7
+	for (my $i = 0; $i <= $#errtext; $i++){
ba46c7
 		$errtext[$i] =~ s/\n//g;
ba46c7
 		print  "\n" . $errtext[$i];
ba46c7
 	} 
ba46c7
@@ -953,51 +920,44 @@ if ($verb eq "yes" || $usage =~ /f/ ){
ba46c7
 		print "\n\n----- Top $sizeCount Failed Logins ------\n\n";
ba46c7
 
ba46c7
 		if ($ds6x eq "true"){
ba46c7
-			%ds6xbadpwd = getCounterHashFromFile($DS6XBADPWD);
ba46c7
-			$ds6loop = 0;
ba46c7
-			foreach $ds6bp (sort { $ds6xbadpwd{$b} <=> $ds6xbadpwd{$a} } keys %ds6xbadpwd) {
ba46c7
-				if ($eloop > $sizeCount){ last; }
ba46c7
-				printf "%-4s        %-40s\n", $ds6xbadpwd{$ds6bp}, $ds6bp;
ba46c7
+			my $ds6xbadpwd = $hashes->{ds6xbadpwd};
ba46c7
+			my $ds6loop = 0;
ba46c7
+			foreach my $ds6bp (sort { $ds6xbadpwd->{$b} <=> $ds6xbadpwd->{$a} } keys %{$ds6xbadpwd}) {
ba46c7
+				if ($ds6loop > $sizeCount){ last; }
ba46c7
+				printf "%-4s        %-40s\n", $ds6xbadpwd->{$ds6bp}, $ds6bp;
ba46c7
 				$ds6loop++;
ba46c7
 			}
ba46c7
-			undef %ds6xbadpwd;
ba46c7
 		} else {
ba46c7
-			getInfoArraysFromFile($BINDINFO);
ba46c7
-			@bindVal = @fileArray1;
ba46c7
-			@bindConn = @fileArray2;
ba46c7
-			@bindOp = @fileArray3;
ba46c7
-			@badPasswordConn = getArrayFromFile($BADPWDCONN);
ba46c7
-			@badPasswordOp = getArrayFromFile($BADPWDOP);
ba46c7
-			@badPasswordIp = getArrayFromFile($BADPWDIP);
ba46c7
-			for ($ii =0 ; $ii < $badPwdCount; $ii++){
ba46c7
-		 		for ($i = 0; $i < $bindCount; $i++){
ba46c7
-					if ($badPasswordConn[$ii] eq $bindConn[$i] && $badPasswordOp[$ii] eq $bindOp[$i] ){
ba46c7
-						$badPassword{ "$bindVal[$i]" } = $badPassword{ "$bindVal[$i]" } + 1;
ba46c7
+			my $bindVal = $arrays->{binddn};
ba46c7
+			my $bindConn = $arrays->{bindconn};
ba46c7
+			my $bindOp = $arrays->{bindop};
ba46c7
+			my $badPasswordConn = $arrays->{badpwdconn};
ba46c7
+			my $badPasswordOp = $arrays->{badpwdop};
ba46c7
+			my $badPasswordIp = $arrays->{badpwdip};
ba46c7
+			my %badPassword = ();
ba46c7
+			for (my $ii =0 ; $ii < $badPwdCount; $ii++){
ba46c7
+		 		for (my $i = 0; $i < $bindCount; $i++){
ba46c7
+					if ($badPasswordConn->[$ii] eq $bindConn->[$i] && $badPasswordOp->[$ii] eq $bindOp->[$i] ){
ba46c7
+						$badPassword{ $bindVal->[$i] }++;
ba46c7
 					}
ba46c7
 		 		}
ba46c7
 			}
ba46c7
 			# sort the new hash of $badPassword{}
ba46c7
-			$bpTotal = 0;
ba46c7
-			$bpCount = 0;
ba46c7
-			foreach $badpw (sort {$badPassword{$b} <=> $badPassword{$a} } keys %badPassword){
ba46c7
+			my $bpTotal = 0;
ba46c7
+			my $bpCount = 0;
ba46c7
+			foreach my $badpw (sort {$badPassword{$b} <=> $badPassword{$a} } keys %badPassword){
ba46c7
 				if ($bpCount > $sizeCount){ last;}
ba46c7
 				$bpCount++;
ba46c7
 				$bpTotal = $bpTotal + $badPassword{"$badpw"};
ba46c7
 				printf "%-4s        %-40s\n", $badPassword{"$badpw"}, $badpw;
ba46c7
 			}
ba46c7
 			print "\nFrom the IP address(s) :\n\n";
ba46c7
-			for ($i=0; $i<$badPwdCount; $i++) {
ba46c7
-				print "\t\t$badPasswordIp[$i]\n";
ba46c7
+			for (my $i=0; $i<$badPwdCount; $i++) {
ba46c7
+				print "\t\t$badPasswordIp->[$i]\n";
ba46c7
 			}
ba46c7
 			if ($bpTotal > $badPwdCount){
ba46c7
 				print "\n** Warning : Wrongly reported failed login attempts : ". ($bpTotal - $badPwdCount) . "\n";
ba46c7
 			}
ba46c7
-			undef @bindVal;
ba46c7
-			undef @bindConn;
ba46c7
-			undef @bindOp;
ba46c7
-			undef @badPasswordConn;
ba46c7
-			undef @badPasswordOp;
ba46c7
-			undef @badPasswordIp;
ba46c7
 		}  # this ends the if $ds6x = true
ba46c7
 	}
ba46c7
 }
ba46c7
@@ -1012,15 +972,14 @@ if ($verb eq "yes" || $usage =~ /f/ ){
ba46c7
 if ($connCodeCount > 0){
ba46c7
 	if ($usage =~ /c/i || $verb eq "yes"){
ba46c7
 		print "\n\n----- Total Connection Codes -----\n\n";
ba46c7
-		%conncount = &getCounterHashFromFile($CONNCOUNT);
ba46c7
-
ba46c7
-	  	foreach $key (sort { $conncount{$b} <=> $conncount{$a} } keys %conncount) {
ba46c7
-		  	if ($conncount{$key} > 0){
ba46c7
-				push @conntext, sprintf "%-4s %6s   %-40s\n",$key,$conncount{$key},$connmsg{ $key };
ba46c7
+		my $conncount = $hashes->{conncount};
ba46c7
+		my @conntext;
ba46c7
+	  	foreach my $key (sort { $conncount->{$b} <=> $conncount->{$a} } keys %{$conncount}) {
ba46c7
+		  	if ($conncount->{$key} > 0){
ba46c7
+				push @conntext, sprintf "%-4s %6s   %-40s\n",$key,$conncount->{$key},$connmsg{ $key };
ba46c7
 		  	}
ba46c7
 	  	}
ba46c7
 		print @conntext;
ba46c7
-		undef %conncount;
ba46c7
 	}
ba46c7
 }
ba46c7
 
ba46c7
@@ -1031,35 +990,36 @@ if ($connCodeCount > 0){
ba46c7
 ########################################
ba46c7
 
ba46c7
 if ($usage =~ /i/i || $verb eq "yes"){
ba46c7
-	%ip_hash = getTwoDimHashFromFile($IP_HASH);
ba46c7
-	%exCount = getCounterHashFromFile($EXCOUNT);
ba46c7
-	@ipkeys = keys %ip_hash;
ba46c7
-	@exxCount = keys %exCount;
ba46c7
-	$ip_count = ($#ipkeys + 1)-($#exxCount + 1); 
ba46c7
+	my $ip_hash = $hashes->{ip_hash};
ba46c7
+	my $exCount = $hashes->{excount};
ba46c7
+	my @ipkeys = keys %{$ip_hash};
ba46c7
+	my @exxCount = keys %${exCount};
ba46c7
+	my $ip_count = ($#ipkeys + 1)-($#exxCount + 1);
ba46c7
+	my $ccount = 0;
ba46c7
 	if ($ip_count > 0){
ba46c7
 	 	print "\n\n----- Top $sizeCount Clients -----\n\n";
ba46c7
 	 	print "Number of Clients:  $ip_count\n\n";
ba46c7
-		foreach $key (sort { $ip_hash{$b}{"count"} <=> $ip_hash{$a}{"count"} } keys %ip_hash) {
ba46c7
-			$exc = "no";
ba46c7
+		foreach my $key (sort { $ip_hash->{$b} <=> $ip_hash->{$a} } @ipkeys) {
ba46c7
+			my $exc = "no";
ba46c7
 			if ($ccount > $sizeCount){ last;}
ba46c7
 			$ccount++;
ba46c7
-			for ($xxx =0; $xxx <= $#excludeIP; $xxx++){
ba46c7
+			for (my $xxx =0; $xxx < $#excludeIP; $xxx++){
ba46c7
 				if ($excludeIP[$xxx] eq $key){$exc = "yes";}
ba46c7
 			}
ba46c7
 			if ($exc ne "yes"){
ba46c7
-				if ($ip_hash{ $key }{"count"} eq ""){$ip_hash{ $key }{"count"} = "?";}
ba46c7
+				if ($ip_hash->{ $key } eq ""){$ip_hash->{ $key } = "?";}
ba46c7
 				printf "[%s] Client: %s\n",$ccount, $key;
ba46c7
-				printf "%10s - Connections\n", $ip_hash{ $key }{"count"};
ba46c7
-				foreach $code (sort { $ip_hash{ $key }{$b} <=> $ip_hash{ $key }{$a} } keys %{$ip_hash{ $key }}) {
ba46c7
+				printf "%10s - Connections\n", $ip_hash->{ $key };
ba46c7
+				my %counts;
ba46c7
+				map { $counts{$_} = $hashes->{$_}->{$key} if (defined($hashes->{$_}->{$key})) } @conncodes;
ba46c7
+				foreach my $code (sort { $counts{$b} <=> $counts{$a} } keys %counts) {
ba46c7
 		 			if ($code eq 'count' ) { next; }
ba46c7
-					printf "%10s - %s (%s)\n", $ip_hash{ $key }{ $code }, $code, $connmsg{ $code };
ba46c7
+					printf "%10s - %s (%s)\n", $counts{ $code }, $code, $connmsg{ $code };
ba46c7
 				}
ba46c7
 				print "\n";
ba46c7
 			}
ba46c7
 		}
ba46c7
 	}
ba46c7
-	undef %exCount;
ba46c7
-	undef %ip_hash;
ba46c7
 }
ba46c7
 
ba46c7
 ###################################
ba46c7
@@ -1069,21 +1029,22 @@ if ($usage =~ /i/i || $verb eq "yes"){
ba46c7
 ###################################
ba46c7
 
ba46c7
 if ($usage =~ /b/i || $verb eq "yes"){
ba46c7
-	%bindlist = getCounterHashFromFile($BINDLIST);
ba46c7
-	@bindkeys = keys %bindlist;
ba46c7
-	$bind_count = $#bindkeys + 1;
ba46c7
+	my $bindlist = $hashes->{bindlist};
ba46c7
+	my @bindkeys = keys %{$bindlist};
ba46c7
+	my $bind_count = $#bindkeys + 1;
ba46c7
 	if ($bind_count > 0){
ba46c7
 		print "\n\n----- Top $sizeCount Bind DN's -----\n\n";
ba46c7
 		print "Number of Unique Bind DN's: $bind_count\n\n"; 
ba46c7
-		$bindcount = 0;
ba46c7
-		foreach $dn (sort { $bindlist{$b} <=> $bindlist{$a} } keys %bindlist) {
ba46c7
-		        if ($bindcount < $sizeCount){
ba46c7
-				printf "%-8s        %-40s\n", $bindlist{ $dn },$dn;
ba46c7
-			}
ba46c7
+		my $bindcount = 0;
ba46c7
+		foreach my $dn (sort { $bindlist->{$b} <=> $bindlist->{$a} } @bindkeys) {
ba46c7
+            if ($bindcount < $sizeCount){
ba46c7
+				printf "%-8s        %-40s\n", $bindlist->{ $dn },$dn;
ba46c7
+			} else {
ba46c7
+                last;
ba46c7
+            }
ba46c7
 			$bindcount++;
ba46c7
 		}
ba46c7
 	}
ba46c7
-	undef %bindlist;
ba46c7
 }
ba46c7
 
ba46c7
 #########################################
ba46c7
@@ -1093,21 +1054,22 @@ if ($usage =~ /b/i || $verb eq "yes"){
ba46c7
 #########################################
ba46c7
 
ba46c7
 if ($usage =~ /a/i || $verb eq "yes"){
ba46c7
-	%base = getCounterHashFromFile($BASE);
ba46c7
-	@basekeys = keys %base;
ba46c7
-	$base_count = $#basekeys + 1;
ba46c7
+	my $base = $hashes->{base};
ba46c7
+	my @basekeys = keys %{$base};
ba46c7
+	my $base_count = $#basekeys + 1;
ba46c7
 	if ($base_count > 0){
ba46c7
 		print "\n\n----- Top $sizeCount Search Bases -----\n\n";
ba46c7
 		print "Number of Unique Search Bases: $base_count\n\n";
ba46c7
-		$basecount = 0;
ba46c7
-		foreach $bas (sort { $base{$b} <=> $base{$a} } keys %base) {
ba46c7
+		my $basecount = 0;
ba46c7
+		foreach my $bas (sort { $base->{$b} <=> $base->{$a} } @basekeys) {
ba46c7
 		        if ($basecount < $sizeCount){
ba46c7
-		                printf "%-8s        %-40s\n", $base{ $bas },$bas;
ba46c7
-		        }
ba46c7
+                    printf "%-8s        %-40s\n", $base->{ $bas },$bas;
ba46c7
+		        } else {
ba46c7
+                    last;
ba46c7
+                }
ba46c7
 		        $basecount++;
ba46c7
 		}
ba46c7
 	}
ba46c7
-	undef %base;
ba46c7
 }
ba46c7
  
ba46c7
 #########################################
ba46c7
@@ -1117,21 +1079,22 @@ if ($usage =~ /a/i || $verb eq "yes"){
ba46c7
 #########################################
ba46c7
 
ba46c7
 if ($usage =~ /l/ || $verb eq "yes"){
ba46c7
-	%filter = getCounterHashFromFile($FILTER);
ba46c7
-	@filterkeys = keys %filter;
ba46c7
-	$filter_count = $#filterkeys + 1;
ba46c7
+	my $filter = $hashes->{filter};
ba46c7
+	my @filterkeys = keys %{$filter};
ba46c7
+	my $filter_count = $#filterkeys + 1;
ba46c7
 	if ($filter_count > 0){
ba46c7
 		print "\n\n----- Top $sizeCount Search Filters -----\n";  
ba46c7
 		print "\nNumber of Unique Search Filters: $filter_count\n\n";
ba46c7
-		$filtercount = 0;
ba46c7
-		foreach $filt (sort { $filter{$b} <=> $filter{$a} } keys %filter){
ba46c7
+		my $filtercount = 0;
ba46c7
+		foreach my $filt (sort { $filter->{$b} <=> $filter->{$a} } @filterkeys){
ba46c7
 			if ($filtercount < $sizeCount){
ba46c7
-				printf "%-8s        %-40s\n", $filter{$filt}, $filt;
ba46c7
-			}
ba46c7
+				printf "%-8s        %-40s\n", $filter->{$filt}, $filt;
ba46c7
+			} else {
ba46c7
+                last;
ba46c7
+            }
ba46c7
 			$filtercount++;
ba46c7
 		}
ba46c7
 	}
ba46c7
-	undef %filter;
ba46c7
 }
ba46c7
 
ba46c7
 #########################################
ba46c7
@@ -1140,20 +1103,23 @@ if ($usage =~ /l/ || $verb eq "yes"){
ba46c7
 #                                       # 
ba46c7
 #########################################
ba46c7
 
ba46c7
+my $first;
ba46c7
 if ($usage =~ /t/i || $verb eq "yes"){
ba46c7
-	%etime = getCounterHashFromFile($ETIME);
ba46c7
+	my $etime = $hashes->{etime};
ba46c7
+	my @ekeys = keys %{$etime};
ba46c7
 	#
ba46c7
 	# print most often etimes
ba46c7
 	#
ba46c7
 	print "\n\n----- Top $sizeCount Most Frequent etimes -----\n\n";
ba46c7
-	$eloop = 0;
ba46c7
-	foreach $et (sort { $etime{$b} <=> $etime{$a} } keys %etime) {
ba46c7
+	my $eloop = 0;
ba46c7
+	my $retime = 0;
ba46c7
+	foreach my $et (sort { $etime->{$b} <=> $etime->{$a} } @ekeys) {
ba46c7
 		if ($eloop == $sizeCount) { last; }
ba46c7
 		if ($retime ne "2"){
ba46c7
 			$first = $et;
ba46c7
 			$retime = "2";
ba46c7
 		}
ba46c7
-		printf "%-8s        %-12s\n", $etime{ $et }, "etime=$et";
ba46c7
+		printf "%-8s        %-12s\n", $etime->{ $et }, "etime=$et";
ba46c7
 		$eloop++;
ba46c7
 	}
ba46c7
 	#
ba46c7
@@ -1161,12 +1127,11 @@ if ($usage =~ /t/i || $verb eq "yes"){
ba46c7
 	#
ba46c7
 	print "\n\n----- Top $sizeCount Longest etimes -----\n\n";
ba46c7
 	$eloop = 0;
ba46c7
-	foreach $et (sort { $b <=> $a } (keys %etime)) {
ba46c7
+	foreach my $et (sort { $b <=> $a } @ekeys) {
ba46c7
 		if ($eloop == $sizeCount) { last; }
ba46c7
-		printf "%-12s    %-10s\n","etime=$et",$etime{ $et };
ba46c7
+		printf "%-12s    %-10s\n","etime=$et",$etime->{ $et };
ba46c7
 		$eloop++;
ba46c7
 	}   
ba46c7
-	undef %etime;
ba46c7
 }
ba46c7
 
ba46c7
 #######################################
ba46c7
@@ -1177,23 +1142,23 @@ if ($usage =~ /t/i || $verb eq "yes"){
ba46c7
 
ba46c7
 
ba46c7
 if ($usage =~ /n/i || $verb eq "yes"){
ba46c7
-	%nentries = getCounterHashFromFile($NENTRIES);
ba46c7
+	my $nentries = $hashes->{nentries};
ba46c7
+	my @nkeys = keys %{$nentries};
ba46c7
 	print "\n\n----- Top $sizeCount Largest nentries -----\n\n";
ba46c7
-	$eloop = 0;
ba46c7
-	foreach $nentry (sort { $b <=> $a } (keys %nentries)){
ba46c7
+	my $eloop = 0;
ba46c7
+	foreach my $nentry (sort { $b <=> $a } @nkeys){
ba46c7
 		if ($eloop == $sizeCount) { last; }
ba46c7
-	    	printf "%-18s   %12s\n","nentries=$nentry", $nentries{ $nentry };
ba46c7
+	    	printf "%-18s   %12s\n","nentries=$nentry", $nentries->{ $nentry };
ba46c7
 		$eloop++;
ba46c7
 	}
ba46c7
 	print "\n\n----- Top $sizeCount Most returned nentries -----\n\n";
ba46c7
 	$eloop = 0;
ba46c7
-	foreach $nentry (sort { $nentries{$b} <=> $nentries{$a} } (keys %nentries)){
ba46c7
+	foreach my $nentry (sort { $nentries->{$b} <=> $nentries->{$a} } @nkeys){
ba46c7
 		if ($eloop == $sizeCount) { last; }
ba46c7
-		printf "%-12s    %-14s\n", $nentries{ $nentry }, "nentries=$nentry";
ba46c7
+		printf "%-12s    %-14s\n", $nentries->{ $nentry }, "nentries=$nentry";
ba46c7
 		$eloop++;
ba46c7
 	}
ba46c7
 	print "\n";
ba46c7
-	undef %nentries;
ba46c7
 }
ba46c7
 
ba46c7
 ##########################################
ba46c7
@@ -1204,9 +1169,10 @@ if ($usage =~ /n/i || $verb eq "yes"){
ba46c7
 
ba46c7
 if ($usage =~ /x/i || $verb eq "yes"){
ba46c7
 	if ($extopCount > 0){
ba46c7
-		%oid = getCounterHashFromFile($OID);
ba46c7
+		my $oid = $hashes->{oid};
ba46c7
 		print "\n\n----- Extended Operations -----\n\n";
ba46c7
-		foreach $oids (sort { $oid{$b} <=> $oid{$a} } (keys %oid) ){
ba46c7
+		foreach my $oids (sort { $oid->{$b} <=> $oid->{$a} } (keys %{$oid}) ){
ba46c7
+			my $oidmessage;
ba46c7
 			if ($oids eq "2.16.840.1.113730.3.5.1"){ $oidmessage = "Transaction Request"} #depreciated?
ba46c7
 			elsif ($oids eq "2.16.840.1.113730.3.5.2"){ $oidmessage = "Transaction Response"} #depreciated?
ba46c7
 			elsif ($oids eq "2.16.840.1.113730.3.5.3"){ $oidmessage = "Start Replication Request (incremental update)"}
ba46c7
@@ -1236,9 +1202,8 @@ if ($usage =~ /x/i || $verb eq "yes"){
ba46c7
 			elsif ($oids eq "1.3.6.1.4.1.4203.1.11.1"){ $oidmessage = "Password Modify"}
ba46c7
 			elsif ($oids eq "2.16.840.1.113730.3.4.20"){ $oidmessage = "MTN Control Use One Backend"}
ba46c7
 			else {$oidmessage = "Other"}
ba46c7
-			printf "%-6s      %-23s     %-60s\n", $oid{ $oids }, $oids, $oidmessage;
ba46c7
+			printf "%-6s      %-23s     %-60s\n", $oid->{ $oids }, $oids, $oidmessage;
ba46c7
 		}
ba46c7
-		undef %oid;
ba46c7
 	}
ba46c7
 }
ba46c7
 
ba46c7
@@ -1250,15 +1215,14 @@ if ($usage =~ /x/i || $verb eq "yes"){
ba46c7
 
ba46c7
 if ($usage =~ /r/i || $verb eq "yes"){
ba46c7
 	if ($anyAttrs > 0){
ba46c7
-		%attr = getCounterHashFromFile($ATTR);
ba46c7
+		my $attr = $hashes->{attr};
ba46c7
 		print "\n\n----- Top $sizeCount Most Requested Attributes -----\n\n";
ba46c7
-		$eloop = 0;
ba46c7
-		foreach $mostAttr (sort { $attr{$b} <=> $attr{$a} } (keys %attr) ){
ba46c7
+		my $eloop = 0;
ba46c7
+		foreach my $mostAttr (sort { $attr->{$b} <=> $attr->{$a} } (keys %{$attr}) ){
ba46c7
 			if ($eloop eq $sizeCount){ last; }
ba46c7
-			printf "%-10s  %-19s\n", $attr{$mostAttr}, $mostAttr;
ba46c7
+			printf "%-10s  %-19s\n", $attr->{$mostAttr}, $mostAttr;
ba46c7
 			$eloop++;
ba46c7
 		}
ba46c7
-		undef %attr;
ba46c7
 	}
ba46c7
 }
ba46c7
 
ba46c7
@@ -1269,77 +1233,59 @@ if ($usage =~ /r/i || $verb eq "yes"){
ba46c7
 #############################
ba46c7
 
ba46c7
 if ($usage =~ /g/i || $verb eq "yes"){
ba46c7
-	$abandonTotal = $srchCount + $delCount + $modCount + $addCount + $modrdnCount + $bindCount + $extopCount + $cmpCount;
ba46c7
+	my $abandonTotal = $srchCount + $delCount + $modCount + $addCount + $modrdnCount + $bindCount + $extopCount + $cmpCount;
ba46c7
 	if ($verb eq "yes" && $abandonCount > 0 && $abandonTotal > 0){
ba46c7
-		%conn_hash = getHashFromFile($CONN_HASH);
ba46c7
-		@srchConn = getArrayFromFile($SRCH_CONN);
ba46c7
-		@srchOp = getArrayFromFile($SRCH_OP);
ba46c7
-		@delConn = getArrayFromFile($DEL_CONN);
ba46c7
-		@delOp = getArrayFromFile($DEL_OP);
ba46c7
-		@targetConn = getArrayFromFile($TARGET_CONN);
ba46c7
-		@targetOp = getArrayFromFile($TARGET_OP);
ba46c7
-		@msgid = getArrayFromFile($MSGID);
ba46c7
-		@addConn = getArrayFromFile($ADD_CONN);
ba46c7
-		@addOp = getArrayFromFile($ADD_OP);
ba46c7
-		@modConn = getArrayFromFile($MOD_CONN);
ba46c7
-		@modOp = getArrayFromFile($MOD_OP);
ba46c7
-		@cmpConn = getArrayFromFile($CMP_CONN);
ba46c7
-		@cmpOp = getArrayFromFile($CMP_OP);
ba46c7
-		@modrdnConn = getArrayFromFile($MODRDN_CONN);
ba46c7
-		@modrdnOp = getArrayFromFile($MODRDN_OP);
ba46c7
-		@bindConn = getArrayFromFile($BIND_CONN);
ba46c7
-		@bindOp = getArrayFromFile($BIND_OP);
ba46c7
-		@unbindConn = getArrayFromFile($UNBIND_CONN);
ba46c7
-		@unbindOp = getArrayFromFile($UNBIND_OP);
ba46c7
-		@extConn = getArrayFromFile($EXT_CONN);
ba46c7
-		@extOp = getArrayFromFile($EXT_OP);
ba46c7
+		my $conn_hash = $hashes->{conn_hash};
ba46c7
 
ba46c7
 		print "\n\n----- Abandon Request Stats -----\n\n";
ba46c7
 
ba46c7
-		for ($g = 0; $g < $abandonCount; $g++){
ba46c7
-			for ($sc = 0; $sc < $srchCount; $sc++){
ba46c7
-				if ($srchConn[$sc] eq $targetConn[$g] && $srchOp[$sc] eq $targetOp[$g] ){
ba46c7
-					print " - SRCH conn=$targetConn[$g] op=$targetOp[$g] msgid=$msgid[$g] client=$conn_hash{$targetConn[$g]}\n";	
ba46c7
+		for (my $g = 0; $g < $abandonCount; $g++){
ba46c7
+			my $conn = $arrays->{targetconn}->[$g];
ba46c7
+			my $op = $arrays->{targetop}->[$g];
ba46c7
+			my $msgid = $arrays->{msgid}->[$g];
ba46c7
+			for (my $sc = 0; $sc < $srchCount; $sc++){
ba46c7
+				if ($arrays->{srchconn}->[$sc] eq $conn && $arrays->{srchop}->[$sc] eq $op ){
ba46c7
+					print " - SRCH conn=$conn op=$op msgid=$msgid client=$conn_hash->{$conn}\n";	
ba46c7
 				}
ba46c7
 			}
ba46c7
-			for ($dc = 0; $dc < $delCount; $dc++){
ba46c7
-				if ($delConn[$dc] eq $targetConn[$g] && $delOp[$dc] eq $targetOp[$g]){
ba46c7
-					print " - DEL conn=$targetConn[$g] op=$targetOp[$g] msgid=$msgid[$g] client=$conn_hash{$targetConn[$g]}\n";
ba46c7
+			for (my $dc = 0; $dc < $delCount; $dc++){
ba46c7
+				if ($arrays->{delconn}->[$dc] eq $conn && $arrays->{delop}->[$dc] eq $op){
ba46c7
+					print " - DEL conn=$conn op=$op msgid=$msgid client=$conn_hash->{$conn}\n";
ba46c7
 				}
ba46c7
 			}
ba46c7
-			for ($adc = 0; $adc < $addCount; $adc++){
ba46c7
-				if ($addConn[$adc] eq $targetConn[$g] && $addOp[$adc] eq $targetOp[$g]){
ba46c7
-					print " - ADD conn=$targetConn[$g] op=$targetOp[$g] msgid=$msgid[$g] client=$conn_hash{$targetConn[$g]}\n";
ba46c7
+			for (my $adc = 0; $adc < $addCount; $adc++){
ba46c7
+				if ($arrays->{addconn}->[$adc] eq $conn && $arrays->{addop}->[$adc] eq $op){
ba46c7
+					print " - ADD conn=$conn op=$op msgid=$msgid client=$conn_hash->{$conn}\n";
ba46c7
 				}
ba46c7
 			}
ba46c7
-			for ($mc = 0; $mc < $modCount; $mc++){
ba46c7
-				if ($modConn[$mc] eq $targetConn[$g] && $modOp[$mc] eq $targetOp[$g]){
ba46c7
-					print " - MOD conn=$targetConn[$g] op=$targetOp[$g] msgid=$msgid[$g] client=$conn_hash{$targetConn[$g]}\n";
ba46c7
+			for (my $mc = 0; $mc < $modCount; $mc++){
ba46c7
+				if ($arrays->{modconn}->[$mc] eq $conn && $arrays->{modop}->[$mc] eq $op){
ba46c7
+					print " - MOD conn=$conn op=$op msgid=$msgid client=$conn_hash->{$conn}\n";
ba46c7
 				}
ba46c7
 			}
ba46c7
-			for ($cc = 0; $cc < $cmpCount; $cc++){
ba46c7
-				if ($cmpConn[$mdc] eq $targetConn[$g] && $cmpOp[$mdc] eq $targetOp[$g]){
ba46c7
-					print " - CMP conn=$targetConn[$g] op=$targetOp[$g] msgid=$msgid[$g] client=$conn_hash{$targetConn[$g]}\n";
ba46c7
+			for (my $cc = 0; $cc < $cmpCount; $cc++){
ba46c7
+				if ($arrays->{cmpconn}->[$cc] eq $conn && $arrays->{cmpop}->[$cc] eq $op){
ba46c7
+					print " - CMP conn=$conn op=$op msgid=$msgid client=$conn_hash->{$conn}\n";
ba46c7
 				}
ba46c7
 			}
ba46c7
-			for ($mdc = 0; $mdc < $modrdnCount; $mdc++){
ba46c7
-				if ($modrdnConn[$mdc] eq $targetConn[$g] && $modrdnOp[$mdc] eq $targetOp[$g]){
ba46c7
-					print " - MODRDN conn=$targetConn[$g] op=$targetOp[$g] msgid=$msgid[$g] client=$conn_hash{$targetConn[$g]}\n";
ba46c7
+			for (my $mdc = 0; $mdc < $modrdnCount; $mdc++){
ba46c7
+				if ($arrays->{modrdnconn}->[$mdc] eq $conn && $arrays->{modrdnop}->[$mdc] eq $op){
ba46c7
+					print " - MODRDN conn=$conn op=$op msgid=$msgid client=$conn_hash->{$conn}\n";
ba46c7
 				}
ba46c7
 			}
ba46c7
-			for ($bcb = 0; $bcb < $bindCount; $bcb++){
ba46c7
-				if ($bindConn[$bcb] eq $targetConn[$g] && $bindOp[$bcb] eq $targetOp[$g]){
ba46c7
-					print " - BIND conn=$targetConn[$g] op=$targetOp[$g] msgid=$msgid[$g] client=$conn_hash{$targetConn[$g]}\n";
ba46c7
+			for (my $bcb = 0; $bcb < $bindCount; $bcb++){
ba46c7
+				if ($arrays->{bindconn}->[$bcb] eq $conn && $arrays->{bindop}->[$bcb] eq $op){
ba46c7
+					print " - BIND conn=$conn op=$op msgid=$msgid client=$conn_hash->{$conn}\n";
ba46c7
 				}
ba46c7
 			}
ba46c7
-			for ($ubc = 0; $ubc < $unbindCount; $ubc++){
ba46c7
-				if ($unbindConn[$ubc] eq $targetConn[$g] && $unbindOp[$ubc] eq $targetOp[$g]){
ba46c7
-					print " - UNBIND conn=$targetConn[$g] op=$targetOp[$g] msgid=$msgid[$g] client=$conn_hash{$targetConn[$g]}\n";
ba46c7
+			for (my $ubc = 0; $ubc < $unbindCount; $ubc++){
ba46c7
+				if ($arrays->{unbindconn}->[$ubc] eq $conn && $arrays->{unbindop}->[$ubc] eq $op){
ba46c7
+					print " - UNBIND conn=$conn op=$op msgid=$msgid client=$conn_hash->{$conn}\n";
ba46c7
 				}
ba46c7
 			}
ba46c7
-			for ($ec = 0; $ec < $extopCount; $ec++){
ba46c7
-				if ($extConn[$ec] eq $targetConn[$g] && $extOp[$ec] eq $targetOp[$g]){
ba46c7
-					print " - EXT conn=$targetConn[$g] op=$targetOp[$g] msgid=$msgid[$g] client=$conn_hash{$targetConn[$g]}\n";
ba46c7
+			for (my $ec = 0; $ec < $extopCount; $ec++){
ba46c7
+				if ($arrays->{extconn}->[$ec] eq $conn && $arrays->{extop}->[$ec] eq $op){
ba46c7
+					print " - EXT conn=$conn op=$op msgid=$msgid client=$conn_hash->{$conn}\n";
ba46c7
 				}
ba46c7
 			}
ba46c7
 		}
ba46c7
@@ -1354,9 +1300,9 @@ print "\n";
ba46c7
 #######################################
ba46c7
 
ba46c7
 if ($usage =~ /j/i || $verb eq "yes"){
ba46c7
-	%conncount = getCounterHashFromFile($CONNCOUNT);
ba46c7
+	my $conncount = $hashes->{conncount};
ba46c7
 	print "\n----- Recommendations -----\n";
ba46c7
-	$recCount = "1";
ba46c7
+	my $recCount = "1";
ba46c7
 	if ($unindexedSrchCountNotesA > 0){
ba46c7
 		print "\n $recCount.  You have unindexed searches, this can be caused from a search on an unindexed attribute, or your returned results exceeded the allidsthreshold.  Unindexed searches are not recommended. To refuse unindexed searches, switch \'nsslapd-require-index\' to \'on\' under your database entry (e.g. cn=UserRoot,cn=ldbm database,cn=plugins,cn=config).\n";
ba46c7
 		$recCount++;
ba46c7
@@ -1365,11 +1311,11 @@ if ($usage =~ /j/i || $verb eq "yes"){
ba46c7
 		print "\n $recCount.  You have unindexed components, this can be caused from a search on an unindexed attribute, or your returned results exceeded the allidsthreshold.  Unindexed components are not recommended. To refuse unindexed searches, switch \'nsslapd-require-index\' to \'on\' under your database entry (e.g. cn=UserRoot,cn=ldbm database,cn=plugins,cn=config).\n";
ba46c7
 		$recCount++;
ba46c7
 	}
ba46c7
-	if ($conncount{"T1"} > 0){
ba46c7
+	if (defined($conncount->{"T1"}) and $conncount->{"T1"} > 0){
ba46c7
 		print "\n $recCount.  You have some connections that are are being closed by the idletimeout setting. You may want to increase the idletimeout if it is set low.\n";
ba46c7
 		$recCount++;
ba46c7
 	}
ba46c7
-	if ($conncount{"T2"} > 0){
ba46c7
+	if (defined($conncount->{"T2"}) and $conncount->{"T2"} > 0){
ba46c7
 		print "\n $recCount.  You have some coonections that are being closed by the ioblocktimeout setting. You may want to increase the ioblocktimeout.\n";
ba46c7
 		$recCount++;
ba46c7
 	}
ba46c7
@@ -1391,7 +1337,7 @@ if ($usage =~ /j/i || $verb eq "yes"){
ba46c7
 		print "\n $recCount.  You have more unsuccessful operations than successful operations.  You should investigate this difference.\n";
ba46c7
 		$recCount++;
ba46c7
 	}
ba46c7
-	if ($conncount{"U1"} < ($connCodeCount - $conncount{"U1"})){
ba46c7
+	if (defined($conncount->{"U1"}) and $conncount->{"U1"} < ($connCodeCount - $conncount->{"U1"})){
ba46c7
 		print "\n $recCount.  You have more abnormal connection codes than cleanly closed connections.  You may want to investigate this difference.\n";
ba46c7
 		$recCount++;
ba46c7
 	}
ba46c7
@@ -1407,7 +1353,6 @@ if ($usage =~ /j/i || $verb eq "yes"){
ba46c7
 		print "\nNone.\n";
ba46c7
 	}
ba46c7
 	print "\n";
ba46c7
-	undef %conncount;
ba46c7
 }
ba46c7
 
ba46c7
 #
ba46c7
@@ -1499,11 +1444,9 @@ parseLineBind {
ba46c7
 	$linesProcessed++;
ba46c7
 	$lineBlockCount++;
ba46c7
 	local $_ = $logline;
ba46c7
+	my $ip;
ba46c7
 
ba46c7
-	if ($lineBlockCount >= $limit){
ba46c7
-		print STDERR sprintf" %10s Lines Processed\n",$linesProcessed;
ba46c7
-		$lineBlockCount="0";
ba46c7
-	}
ba46c7
+	statusreport();
ba46c7
 
ba46c7
 	# skip blank lines
ba46c7
 	return if $_ =~ /^\s/;
ba46c7
@@ -1531,7 +1474,8 @@ parseLineBind {
ba46c7
         	}
ba46c7
 	}
ba46c7
 	if ($_ =~ /connection from *([0-9A-Fa-f\.\:]+)/i ) {
ba46c7
-		for ($excl =0; $excl <= $#excludeIP; $excl++){
ba46c7
+		my $skip = "yes";
ba46c7
+		for (my $excl =0; $excl < $#excludeIP; $excl++){
ba46c7
 			if ($excludeIP[$excl] eq $1){
ba46c7
 				$skip = "yes";
ba46c7
 				last;
ba46c7
@@ -1547,6 +1491,7 @@ parseLineBind {
ba46c7
 		return;
ba46c7
 	}
ba46c7
  	if (/ BIND/ && $_ =~ /dn=\"(.*)\" method/i ){
ba46c7
+		my $dn;
ba46c7
         	if ($1 eq ""){
ba46c7
 			$dn = "Anonymous";
ba46c7
 		} else {
ba46c7
@@ -1599,30 +1544,36 @@ parseLineBind {
ba46c7
 sub
ba46c7
 processOpForBindReport
ba46c7
 {
ba46c7
-	$op = @_[0];
ba46c7
-	$data = @_[1];
ba46c7
+	my $op = shift;
ba46c7
+	my $data = shift;
ba46c7
 
ba46c7
 	if ($data =~ /conn= *([0-9]+)/i) {
ba46c7
-		foreach $dn (keys %bindReport){
ba46c7
+		foreach my $dn (keys %bindReport){
ba46c7
 			if ($bindReport{$dn}{"conn"} =~ / $1 /){
ba46c7
-				$bindDN = $dn;
ba46c7
-				$bindReport{$bindDN}{$op}++;
ba46c7
+				$bindReport{$dn}{$op}++;
ba46c7
 				return;
ba46c7
 			}
ba46c7
 		}
ba46c7
 	}
ba46c7
 }
ba46c7
 
ba46c7
+my ($last_tm, $lastzone, $last_min, $gmtime, $tzoff);
ba46c7
 sub parseLineNormal
ba46c7
 {
ba46c7
 	local $_ = $logline;
ba46c7
+	my $ip;
ba46c7
+	my $tmpp;
ba46c7
+	my $exc = "no";
ba46c7
+	my $connID;
ba46c7
+	my $con;
ba46c7
+	my $op;
ba46c7
+	$linesProcessed++;
ba46c7
+	$lineBlockCount++;
ba46c7
 
ba46c7
 	# lines starting blank are restart
ba46c7
 	return if $_ =~ /^\s/;
ba46c7
 
ba46c7
-	$linesProcessed++;
ba46c7
-	$lineBlockCount++;
ba46c7
-	if ($lineBlockCount >= $limit){ print STDERR sprintf" %10s Lines Processed\n",$linesProcessed; $lineBlockCount="0";}
ba46c7
+	statusreport();
ba46c7
 
ba46c7
 	# gather/process the timestamp
ba46c7
 	if($firstFile == 1 && $_ =~ /^\[/){
ba46c7
@@ -1648,30 +1599,30 @@ sub parseLineNormal
ba46c7
 	}
ba46c7
 
ba46c7
 	# Additional performance stats
ba46c7
-	($time, $tzone) = split (' ', $_);
ba46c7
-	if ($reportStats && $time ne $last_tm)
ba46c7
+	my ($time, $tzone) = split (' ', $_);
ba46c7
+	if (($reportStats or ($verb eq "yes") || ($usage =~ /y/)) && (!defined($last_tm) or ($time ne $last_tm)))
ba46c7
 	{
ba46c7
 		$last_tm = $time;
ba46c7
 		$time =~ s/\[//;
ba46c7
 		$tzone =~ s/\].*//;
ba46c7
 
ba46c7
-		if($tzone ne $lastzone)
ba46c7
+		if(!defined($lastzone) or $tzone ne $lastzone)
ba46c7
 		{
ba46c7
 		    # tz offset change
ba46c7
 		    $lastzone=$tzone;
ba46c7
-		    ($sign,$hr,$min) = $tzone =~ m/(.)(\d\d)(\d\d)/;
ba46c7
+		    my ($sign,$hr,$min) = $tzone =~ m/(.)(\d\d)(\d\d)/;
ba46c7
 		    $tzoff = $hr*3600 + $min*60;
ba46c7
 		    $tzoff *= -1
ba46c7
 		    if $sign eq '-';
ba46c7
 		    # to be subtracted from converted values.
ba46c7
 		}
ba46c7
-		($date, $hr, $min, $sec) = split (':', $time);
ba46c7
-		($day, $mon, $yr) = split ('/', $date);
ba46c7
-		$newmin = timegm(0, $min, $hr, $day, $monthname{$mon}, $yr) - $tzoff;
ba46c7
+		my ($date, $hr, $min, $sec) = split (':', $time);
ba46c7
+		my ($day, $mon, $yr) = split ('/', $date);
ba46c7
+		my $newmin = timegm(0, $min, $hr, $day, $monthname{$mon}, $yr) - $tzoff;
ba46c7
 		$gmtime = $newmin + $sec;
ba46c7
 		print_stats_block( $s_stats );
ba46c7
 		reset_stats_block( $s_stats, $gmtime, $time.' '.$tzone );
ba46c7
-		if ($newmin != $last_min)
ba46c7
+		if (!defined($last_min) or $newmin != $last_min)
ba46c7
 		{
ba46c7
 		    print_stats_block( $m_stats );
ba46c7
 		    $time =~ s/\d\d$/00/;
ba46c7
@@ -1689,58 +1640,57 @@ sub parseLineNormal
ba46c7
 		if($reportStats){ inc_stats('srch',$s_stats,$m_stats); }
ba46c7
 		if ($_ =~ / attrs=\"(.*)\"/i){
ba46c7
 			$anyAttrs++;
ba46c7
-			$attrs = $1 . " ";
ba46c7
-			while ($attrs =~ /(\S+)\s/g){
ba46c7
-				writeFile($ATTR, $1);
ba46c7
-			}
ba46c7
-		} 
ba46c7
+			my $attr = $hashes->{attr};
ba46c7
+			map { $attr->{$_}++ } split /\s/, $1;
ba46c7
+		}
ba46c7
 		if (/ attrs=ALL/){
ba46c7
-			writeFile($ATTR, "All Attributes");
ba46c7
+			my $attr = $hashes->{attr};
ba46c7
+			$attr->{"All Attributes"}++;
ba46c7
 			$anyAttrs++;
ba46c7
 		}
ba46c7
-		if ($verb eq "yes"){ 
ba46c7
-			if ($_ =~ /conn= *([0-9]+)/i){ writeFile($SRCH_CONN, $1);}
ba46c7
-			if ($_ =~ /op= *([0-9]+)/i){ writeFile($SRCH_OP, $1);}
ba46c7
+		if ($verb eq "yes"){
ba46c7
+			if ($_ =~ /conn= *([0-9]+)/i){ push @{$arrays->{srchconn}}, $1;}
ba46c7
+			if ($_ =~ /op= *([0-9]+)/i){ push @{$arrays->{srchop}}, $1;}
ba46c7
 		}
ba46c7
 	}
ba46c7
 	if (m/ DEL/){
ba46c7
 		$delCount++;
ba46c7
 		if($reportStats){ inc_stats('del',$s_stats,$m_stats); }
ba46c7
 		if ($verb eq "yes"){
ba46c7
-			if ($_ =~ /conn= *([0-9]+)/i){ writeFile($DEL_CONN, $1);}
ba46c7
-			if ($_ =~ /op= *([0-9]+)/i){ writeFile($DEL_OP, $1);}
ba46c7
+			if ($_ =~ /conn= *([0-9]+)/i){ push @{$arrays->{delconn}}, $1;}
ba46c7
+			if ($_ =~ /op= *([0-9]+)/i){ push @{$arrays->{delop}}, $1;}
ba46c7
 		}
ba46c7
 	}
ba46c7
 	if (m/ MOD dn=/){
ba46c7
 		$modCount++;
ba46c7
 		if($reportStats){ inc_stats('mod',$s_stats,$m_stats); }
ba46c7
 		if ($verb eq "yes"){
ba46c7
-		        if ($_ =~ /conn= *([0-9]+)/i){ writeFile($MOD_CONN, $1);}
ba46c7
-			if ($_ =~ /op= *([0-9]+)/i){ writeFile($MOD_OP, $1); }
ba46c7
+		        if ($_ =~ /conn= *([0-9]+)/i){ push @{$arrays->{modconn}}, $1;}
ba46c7
+			if ($_ =~ /op= *([0-9]+)/i){ push @{$arrays->{modop}}, $1; }
ba46c7
 		}
ba46c7
 	}
ba46c7
 	if (m/ ADD/){
ba46c7
 		$addCount++;
ba46c7
 		if($reportStats){ inc_stats('add',$s_stats,$m_stats); }
ba46c7
 		if ($verb eq "yes"){
ba46c7
-		        if ($_ =~ /conn= *([0-9]+)/i){ writeFile($ADD_CONN, $1); }
ba46c7
-			if ($_ =~ /op= *([0-9]+)/i){ writeFile($ADD_OP, $1); }
ba46c7
+		        if ($_ =~ /conn= *([0-9]+)/i){ push @{$arrays->{addconn}}, $1; }
ba46c7
+			if ($_ =~ /op= *([0-9]+)/i){ push @{$arrays->{addop}}, $1; }
ba46c7
 		}
ba46c7
 	}
ba46c7
 	if (m/ MODRDN/){
ba46c7
 		$modrdnCount++;
ba46c7
 		if($reportStats){ inc_stats('modrdn',$s_stats,$m_stats); }
ba46c7
 		if ($verb eq "yes"){
ba46c7
-		        if ($_ =~ /conn= *([0-9]+)/i){ writeFile($MODRDN_CONN, $1); }
ba46c7
-			if ($_ =~ /op= *([0-9]+)/i){ writeFile($MODRDN_OP, $1); }
ba46c7
+		        if ($_ =~ /conn= *([0-9]+)/i){ push @{$arrays->{modrdnconn}}, $1; }
ba46c7
+			if ($_ =~ /op= *([0-9]+)/i){ push @{$arrays->{modrdnop}}, $1; }
ba46c7
 		}
ba46c7
 	}
ba46c7
 	if (m/ CMP dn=/){
ba46c7
 		$cmpCount++;
ba46c7
 		if($reportStats){ inc_stats('cmp',$s_stats,$m_stats); }
ba46c7
 		if ($verb eq "yes"  || $usage =~ /g/i){
ba46c7
-			if ($_ =~ /conn= *([0-9]+)/i){ writeFile($CMP_CONN, $1);}
ba46c7
-			if ($_ =~ /op= *([0-9]+)/i){ writeFile($CMP_OP, $1);}
ba46c7
+			if ($_ =~ /conn= *([0-9]+)/i){ push @{$arrays->{cmpconn}}, $1;}
ba46c7
+			if ($_ =~ /op= *([0-9]+)/i){ push @{$arrays->{cmpop}}, $1;}
ba46c7
 		}
ba46c7
 	}
ba46c7
 	if (m/ ABANDON /){
ba46c7
@@ -1748,9 +1698,9 @@ sub parseLineNormal
ba46c7
 		if($reportStats){ inc_stats('abandon',$s_stats,$m_stats); }
ba46c7
 		$allResults++;
ba46c7
 		if ($_ =~ /targetop= *([0-9a-zA-Z]+)/i ){
ba46c7
-			writeFile($TARGET_OP, $1);
ba46c7
-			if ($_ =~ /conn= *([0-9]+)/i){ writeFile($TARGET_CONN, $1); }
ba46c7
-			if ($_ =~ /msgid= *([0-9]+)/i){ writeFile($MSGID, $1);}
ba46c7
+			push @{$arrays->{targetop}}, $1;
ba46c7
+			if ($_ =~ /conn= *([0-9]+)/i){ push @{$arrays->{targetconn}}, $1; }
ba46c7
+			if ($_ =~ /msgid= *([0-9]+)/i){ push @{$arrays->{msgid}}, $1; }
ba46c7
 		}
ba46c7
 	}
ba46c7
 	if (m/ VLV /){
ba46c7
@@ -1774,20 +1724,19 @@ sub parseLineNormal
ba46c7
 		if ($1 ne ""){ 
ba46c7
 			$tmpp = $1;
ba46c7
 			$tmpp =~ tr/A-Z/a-z/;
ba46c7
-			writeFile($BINDLIST, $tmpp); 
ba46c7
+			$hashes->{bindlist}->{$tmpp}++;
ba46c7
 			if($1 eq $rootDN){ 
ba46c7
 				$rootDNBindCount++;
ba46c7
 			}
ba46c7
 		} else {
ba46c7
 			$anonymousBindCount++;
ba46c7
-			writeFile($BINDLIST, "Anonymous Binds");
ba46c7
+			$hashes->{bindlist}->{"Anonymous Binds"}++;
ba46c7
 			inc_stats('anonbind',$s_stats,$m_stats);
ba46c7
 		}
ba46c7
 	}
ba46c7
 	if (m/ connection from/){
ba46c7
-		$exc = "no";
ba46c7
 		if ($_ =~ /connection from *([0-9A-Fa-f\.\:]+)/i ){ 
ba46c7
-			for ($xxx =0; $xxx <= $#excludeIP; $xxx++){
ba46c7
+			for (my $xxx =0; $xxx < $#excludeIP; $xxx++){
ba46c7
 				if ($excludeIP[$xxx] eq $1){$exc = "yes";}
ba46c7
 			}
ba46c7
 			if ($exc ne "yes"){
ba46c7
@@ -1801,11 +1750,13 @@ sub parseLineNormal
ba46c7
 		}
ba46c7
 		($connID) = $_ =~ /conn=(\d*)\s/;
ba46c7
 		$openConnection[$connID]++;
ba46c7
-		($time, $tzone) = split (' ', $_);
ba46c7
-		($date, $hr, $min, $sec) = split (':', $time);
ba46c7
-		($day, $mon, $yr) = split ('/', $date);
ba46c7
-		$day =~ s/\[//;
ba46c7
-		$start_time_of_connection[$connID] = timegm($sec, $min, $hours, $day, $monthname{$mon}, $yr);
ba46c7
+		if ($reportStats or ($verb eq "yes") || ($usage =~ /y/)) {
ba46c7
+			my ($time, $tzone) = split (' ', $_);
ba46c7
+			my ($date, $hr, $min, $sec) = split (':', $time);
ba46c7
+			my ($day, $mon, $yr) = split ('/', $date);
ba46c7
+			$day =~ s/\[//;
ba46c7
+			$start_time_of_connection[$connID] = timegm($sec, $min, $hr, $day, $monthname{$mon}, $yr);
ba46c7
+		}
ba46c7
 	}
ba46c7
 	if (m/ SSL client bound as /){$sslClientBindCount++;}
ba46c7
 	if (m/ SSL failed to map client certificate to LDAP DN/){$sslClientFailedCount++;}
ba46c7
@@ -1816,16 +1767,22 @@ sub parseLineNormal
ba46c7
 
ba46c7
 		($connID) = $_ =~ /conn=(\d*)\s/;
ba46c7
 		$openConnection[$connID]--;
ba46c7
-		$end_time_of_connection[$connID] = $gmtime;
ba46c7
-		$diff = $end_time_of_connection[$connID] - $start_time_of_connection[$connID];
ba46c7
-		$start_time_of_connection[$connID] =  $end_time_of_connection[$connID] = 0;
ba46c7
-		if ($diff <= 1) { $latency[0]++;}
ba46c7
-		if ($diff == 2) { $latency[1]++;}
ba46c7
-		if ($diff == 3) { $latency[2]++;}
ba46c7
-		if ($diff >= 4 && $diff <=5 ) { $latency[3]++;}
ba46c7
-		if ($diff >= 6 && $diff <=10 ) { $latency[4]++;}
ba46c7
-		if ($diff >= 11 && $diff <=15 ) { $latency[5]++;}
ba46c7
-		if ($diff >= 16) { $latency[6] ++;}
ba46c7
+		if ($reportStats or ($verb eq "yes") || ($usage =~ /y/)) {
ba46c7
+			# if we didn't see the start time of this connection
ba46c7
+			# i.e. due to truncation or log rotation
ba46c7
+			# then just set to 0
ba46c7
+			my $stoc = $start_time_of_connection[$connID] || 0;
ba46c7
+			$end_time_of_connection[$connID] = $gmtime || 0;
ba46c7
+			my $diff = $end_time_of_connection[$connID] - $stoc;
ba46c7
+			$start_time_of_connection[$connID] =  $end_time_of_connection[$connID] = 0;
ba46c7
+			if ($diff <= 1) { $latency[0]++;}
ba46c7
+			if ($diff == 2) { $latency[1]++;}
ba46c7
+			if ($diff == 3) { $latency[2]++;}
ba46c7
+			if ($diff >= 4 && $diff <=5 ) { $latency[3]++;}
ba46c7
+			if ($diff >= 6 && $diff <=10 ) { $latency[4]++;}
ba46c7
+			if ($diff >= 11 && $diff <=15 ) { $latency[5]++;}
ba46c7
+			if ($diff >= 16) { $latency[6] ++;}
ba46c7
+		}
ba46c7
 	}
ba46c7
 	if (m/ BIND/ && $_ =~ /dn=\"(.*)\" method/i ){
ba46c7
 		if($reportStats){ inc_stats('bind',$s_stats,$m_stats); }
ba46c7
@@ -1834,25 +1791,26 @@ sub parseLineNormal
ba46c7
 			if($1 eq $rootDN){$rootDNBindCount++;}
ba46c7
 			$tmpp = $1;
ba46c7
 			$tmpp =~ tr/A-Z/a-z/;
ba46c7
-			writeFile($BINDLIST, $tmpp); 
ba46c7
-			$bindVal = $tmpp;
ba46c7
-			if ($_ =~ /conn= *([0-9]+)/i) { $bindConn = $1; writeFile($BIND_CONN, $1);}
ba46c7
-			if ($_ =~ /op= *([0-9]+)/i) { $bindOp = $1; writeFile($BIND_OP, $1);}
ba46c7
+			$hashes->{bindlist}->{$tmpp}++;
ba46c7
+			if ($_ =~ /conn= *([0-9]+)/i) { push @{$arrays->{bindconn}}, $1;}
ba46c7
+			if ($_ =~ /op= *([0-9]+)/i) { push @{$arrays->{bindop}}, $1;}
ba46c7
 			if($usage =~ /f/ || $verb eq "yes"){
ba46c7
-				# only need this for the failed bind report
ba46c7
-				writeFile($BINDINFO, "$bindVal ,, $bindConn ,, $bindOp");
ba46c7
+				push @{$arrays->{binddn}}, $tmpp;
ba46c7
 			}
ba46c7
 		} else {
ba46c7
 			$anonymousBindCount++;
ba46c7
-			writeFile($BINDLIST, "Anonymous Binds");
ba46c7
+			$hashes->{bindlist}->{"Anonymous Binds"}++;
ba46c7
+			if ($_ =~ /conn= *([0-9]+)/i) { push @{$arrays->{bindconn}}, $1;}
ba46c7
+			if ($_ =~ /op= *([0-9]+)/i) { push @{$arrays->{bindop}}, $1;}
ba46c7
+			push @{$arrays->{binddn}}, "";
ba46c7
 			inc_stats('anonbind',$s_stats,$m_stats);
ba46c7
 		}
ba46c7
 	}
ba46c7
 	if (m/ UNBIND/){
ba46c7
 		$unbindCount++;
ba46c7
 		if ($verb eq "yes"){
ba46c7
-		        if ($_ =~ /conn= *([0-9]+)/i){ writeFile($UNBIND_CONN, $1); }
ba46c7
-			if ($_ =~ /op= *([0-9]+)/i){ writeFile($UNBIND_OP, $1); }
ba46c7
+		        if ($_ =~ /conn= *([0-9]+)/i){ push @{$arrays->{unbindconn}}, $1; }
ba46c7
+			if ($_ =~ /op= *([0-9]+)/i){ push @{$arrays->{unbindop}}, $1; }
ba46c7
 		}
ba46c7
 	}
ba46c7
 	if (m/ RESULT err=/ && m/ notes=P/){
ba46c7
@@ -1863,7 +1821,7 @@ sub parseLineNormal
ba46c7
 		        $con = $1;
ba46c7
 		        if ($_ =~ /op= *([0-9]+)/i){ $op = $1;}
ba46c7
 		}
ba46c7
-		for ($i=0; $i <= $vlvCount;$i++){
ba46c7
+		for (my $i=0; $i <= $vlvCount;$i++){
ba46c7
 		        if ($vlvconn[$i] eq $con && $vlvop[$i] eq $op){ $vlvNotesACount++; $isVlvNotes="1";}
ba46c7
 		}
ba46c7
 		if($isVlvNotes == 0){
ba46c7
@@ -1873,22 +1831,12 @@ sub parseLineNormal
ba46c7
 			if($reportStats){ inc_stats('notesA',$s_stats,$m_stats); }
ba46c7
 		}
ba46c7
 		if ($usage =~ /u/ || $verb eq "yes"){
ba46c7
-			if ($isVlvNnotes == 0 ){
ba46c7
-		        	if ($_ =~ /etime= *([0-9.]+)/i ){
ba46c7
-		                	writeFile($NOTES_A_ETIME, $1);
ba46c7
-		        	}
ba46c7
-		        	if ($_ =~ /conn= *([0-9]+)/i){
ba46c7
-		                	writeFile($NOTES_A_CONN, $1);
ba46c7
-		        	}
ba46c7
-		        	if ($_ =~ /op= *([0-9]+)/i){
ba46c7
-		                	writeFile($NOTES_A_OP, $1);
ba46c7
-		        	}
ba46c7
-		        	if ($_ =~ / *([0-9a-z:\/]+)/i){
ba46c7
-		                	writeFile($NOTES_A_TIME, $1);
ba46c7
-		        	}
ba46c7
-				if ($_ =~ /nentries= *([0-9]+)/i ){
ba46c7
-					writeFile($NOTES_A_NENTRIES, $1);
ba46c7
-				}
ba46c7
+			if ($isVlvNotes == 0 ){
ba46c7
+		        	if ($_ =~ /etime= *([0-9.]+)/i ){ push @{$arrays->{notesAetime}}, $1; }
ba46c7
+		        	if ($_ =~ /conn= *([0-9]+)/i){ push @{$arrays->{notesAconn}}, $1; }
ba46c7
+		        	if ($_ =~ /op= *([0-9]+)/i){ push @{$arrays->{notesAop}}, $1; }
ba46c7
+		        	if ($_ =~ / *([0-9a-z:\/]+)/i){ push @{$arrays->{notesAtime}}, $1; }
ba46c7
+				if ($_ =~ /nentries= *([0-9]+)/i ){ push @{$arrays->{notesAnentries}}, $1; }
ba46c7
 			}
ba46c7
 		}
ba46c7
 		$isVlvNotes = 0;
ba46c7
@@ -1898,7 +1846,7 @@ sub parseLineNormal
ba46c7
 		        $con = $1;
ba46c7
 		        if ($_ =~ /op= *([0-9]+)/i){ $op = $1;}
ba46c7
 		}
ba46c7
-		for ($i=0; $i <= $vlvCount;$i++){
ba46c7
+		for (my $i=0; $i <= $vlvCount;$i++){
ba46c7
 		        if ($vlvconn[$i] eq $con && $vlvop[$i] eq $op){ $vlvNotesUCount++; $isVlvNotes="1";}
ba46c7
 		}
ba46c7
 		if($isVlvNotes == 0){
ba46c7
@@ -1908,85 +1856,75 @@ sub parseLineNormal
ba46c7
 			if($reportStats){ inc_stats('notesU',$s_stats,$m_stats); }
ba46c7
 		}
ba46c7
 		if ($usage =~ /u/ || $verb eq "yes"){
ba46c7
-			if ($isVlvNnotes == 0 ){
ba46c7
-		        	if ($_ =~ /etime= *([0-9.]+)/i ){
ba46c7
-		                	writeFile($NOTES_U_ETIME, $1);
ba46c7
-		        	}
ba46c7
-		        	if ($_ =~ /conn= *([0-9]+)/i){
ba46c7
-		                	writeFile($NOTES_U_CONN, $1);
ba46c7
-		        	}
ba46c7
-		        	if ($_ =~ /op= *([0-9]+)/i){
ba46c7
-		                	writeFile($NOTES_U_OP, $1);
ba46c7
-		        	}
ba46c7
-		        	if ($_ =~ / *([0-9a-z:\/]+)/i){
ba46c7
-		                	writeFile($NOTES_U_TIME, $1);
ba46c7
-		        	}
ba46c7
-				if ($_ =~ /nentries= *([0-9]+)/i ){
ba46c7
-					writeFile($NOTES_U_NENTRIES, $1);
ba46c7
-				}
ba46c7
+			if ($isVlvNotes == 0 ){
ba46c7
+		        	if ($_ =~ /etime= *([0-9.]+)/i ){ push @{$arrays->{notesUetime}}, $1; }
ba46c7
+		        	if ($_ =~ /conn= *([0-9]+)/i){ push @{$arrays->{notesUconn}}, $1; }
ba46c7
+		        	if ($_ =~ /op= *([0-9]+)/i){ push @{$arrays->{notesUop}}, $1; }
ba46c7
+		        	if ($_ =~ / *([0-9a-z:\/]+)/i){ push @{$arrays->{notesUtime}}, $1; }
ba46c7
+				if ($_ =~ /nentries= *([0-9]+)/i ){ push @{$arrays->{notesUnentries}}, $1; }
ba46c7
 			}
ba46c7
 		}
ba46c7
 		$isVlvNotes = 0;
ba46c7
 	}
ba46c7
 	if (m/ closed error 32/){
ba46c7
 		$brokenPipeCount++;
ba46c7
-		if (m/- T1/){ writeFile($RC,"T1"); }
ba46c7
-		elsif (m/- T2/){ writeFile($RC,"T2"); }
ba46c7
-		elsif (m/- A1/){ writeFile($RC,"A1"); }
ba46c7
-		elsif (m/- B1/){ writeFile($RC,"B1"); }
ba46c7
-		elsif (m/- B4/){ writeFile($RC,"B4"); }
ba46c7
-		elsif (m/- B2/){ writeFile($RC,"B2"); }
ba46c7
-		elsif (m/- B3/){ writeFile($RC,"B3"); }
ba46c7
-		elsif (m/- R1/){ writeFile($RC,"R1"); }
ba46c7
-		elsif (m/- P1/){ writeFile($RC,"P1"); }
ba46c7
-		elsif (m/- P1/){ writeFile($RC,"P2"); }
ba46c7
-		elsif (m/- U1/){ writeFile($RC,"U1"); }
ba46c7
-		else { writeFile($RC,"other"); }
ba46c7
+		if (m/- T1/){ $hashes->{rc}->{"T1"}++; }
ba46c7
+		elsif (m/- T2/){ $hashes->{rc}->{"T2"}++; }
ba46c7
+		elsif (m/- A1/){ $hashes->{rc}->{"A1"}++; }
ba46c7
+		elsif (m/- B1/){ $hashes->{rc}->{"B1"}++; }
ba46c7
+		elsif (m/- B4/){ $hashes->{rc}->{"B4"}++; }
ba46c7
+		elsif (m/- B2/){ $hashes->{rc}->{"B2"}++; }
ba46c7
+		elsif (m/- B3/){ $hashes->{rc}->{"B3"}++; }
ba46c7
+		elsif (m/- R1/){ $hashes->{rc}->{"R1"}++; }
ba46c7
+		elsif (m/- P1/){ $hashes->{rc}->{"P1"}++; }
ba46c7
+		elsif (m/- P1/){ $hashes->{rc}->{"P2"}++; }
ba46c7
+		elsif (m/- U1/){ $hashes->{rc}->{"U1"}++; }
ba46c7
+		else { $hashes->{rc}->{"other"}++; }
ba46c7
 	}
ba46c7
 	if (m/ closed error 131/ || m/ closed error -5961/){
ba46c7
 		$connResetByPeerCount++;
ba46c7
-		if (m/- T1/){ writeFile($SRC,"T1"); }
ba46c7
-		elsif (m/- T2/){ writeFile($SRC,"T2"); }
ba46c7
-		elsif (m/- A1/){ writeFile($SRC,"A1"); }
ba46c7
-		elsif (m/- B1/){ writeFile($SRC,"B1"); }
ba46c7
-		elsif (m/- B4/){ writeFile($SRC,"B4"); }
ba46c7
-		elsif (m/- B2/){ writeFile($SRC,"B2"); }
ba46c7
-		elsif (m/- B3/){ writeFile($SRC,"B3"); }
ba46c7
-		elsif (m/- R1/){ writeFile($SRC,"R1"); }
ba46c7
-		elsif (m/- P1/){ writeFile($SRC,"P1"); }
ba46c7
-		elsif (m/- P1/){ writeFile($SRC,"P2"); }
ba46c7
-		elsif (m/- U1/){ writeFile($SRC,"U1"); }
ba46c7
-		else { writeFile($SRC,"other"); }
ba46c7
+		if (m/- T1/){ $hashes->{src}->{"T1"}++; }
ba46c7
+		elsif (m/- T2/){ $hashes->{src}->{"T2"}++; }
ba46c7
+		elsif (m/- A1/){ $hashes->{src}->{"A1"}++; }
ba46c7
+		elsif (m/- B1/){ $hashes->{src}->{"B1"}++; }
ba46c7
+		elsif (m/- B4/){ $hashes->{src}->{"B4"}++; }
ba46c7
+		elsif (m/- B2/){ $hashes->{src}->{"B2"}++; }
ba46c7
+		elsif (m/- B3/){ $hashes->{src}->{"B3"}++; }
ba46c7
+		elsif (m/- R1/){ $hashes->{src}->{"R1"}++; }
ba46c7
+		elsif (m/- P1/){ $hashes->{src}->{"P1"}++; }
ba46c7
+		elsif (m/- P1/){ $hashes->{src}->{"P2"}++; }
ba46c7
+		elsif (m/- U1/){ $hashes->{src}->{"U1"}++; }
ba46c7
+		else { $hashes->{src}->{"other"}++; }
ba46c7
 	}
ba46c7
 	if (m/ closed error 11/){
ba46c7
 		$resourceUnavailCount++;
ba46c7
-		if (m/- T1/){ writeFile($RSRC,"T1"); }
ba46c7
-		elsif (m/- T2/){ writeFile($RSRC,"T2"); }
ba46c7
-		elsif (m/- A1/){ writeFile($RSRC,"A1"); }
ba46c7
-		elsif (m/- B1/){ writeFile($RSRC,"B1"); }
ba46c7
-		elsif (m/- B4/){ writeFile($RSRC,"B4"); }
ba46c7
-		elsif (m/- B2/){ writeFile($RSRC,"B2"); }
ba46c7
-		elsif (m/- B3/){ writeFile($RSRC,"B3"); }
ba46c7
-		elsif (m/- R1/){ writeFile($RSRC,"R1"); }
ba46c7
-		elsif (m/- P1/){ writeFile($RSRC,"P1"); }
ba46c7
-		elsif (m/- P1/){ writeFile($RSRC,"P2"); }
ba46c7
-		elsif (m/- U1/){ writeFile($RSRC,"U1"); }
ba46c7
-		else { writeFile($RSRC,"other"); }
ba46c7
+		if (m/- T1/){ $hashes->{rsrc}->{"T1"}++; }
ba46c7
+		elsif (m/- T2/){ $hashes->{rsrc}->{"T2"}++; }
ba46c7
+		elsif (m/- A1/){ $hashes->{rsrc}->{"A1"}++; }
ba46c7
+		elsif (m/- B1/){ $hashes->{rsrc}->{"B1"}++; }
ba46c7
+		elsif (m/- B4/){ $hashes->{rsrc}->{"B4"}++; }
ba46c7
+		elsif (m/- B2/){ $hashes->{rsrc}->{"B2"}++; }
ba46c7
+		elsif (m/- B3/){ $hashes->{rsrc}->{"B3"}++; }
ba46c7
+		elsif (m/- R1/){ $hashes->{rsrc}->{"R1"}++; }
ba46c7
+		elsif (m/- P1/){ $hashes->{rsrc}->{"P1"}++; }
ba46c7
+		elsif (m/- P1/){ $hashes->{rsrc}->{"P2"}++; }
ba46c7
+		elsif (m/- U1/){ $hashes->{rsrc}->{"U1"}++; }
ba46c7
+		else { $hashes->{rsrc}->{"other"}++; }
ba46c7
 	}
ba46c7
 	if ($usage =~ /g/ || $usage =~ /c/ || $usage =~ /i/ || $verb eq "yes"){
ba46c7
 		$exc = "no";
ba46c7
 		if ($_ =~ /connection from *([0-9A-fa-f\.\:]+)/i ) {
ba46c7
-			for ($xxx = 0; $xxx <= $#excludeIP; $xxx++){
ba46c7
+			for (my $xxx = 0; $xxx < $#excludeIP; $xxx++){
ba46c7
 				if ($1 eq $excludeIP[$xxx]){
ba46c7
 					$exc = "yes";
ba46c7
-					writeFile($EXCOUNT,$1);
ba46c7
+					$hashes->{excount}->{$1}++;
ba46c7
 				}
ba46c7
 			}
ba46c7
 			$ip = $1;
ba46c7
-			writeFile($IP_HASH, "$ip count");
ba46c7
+			$hashes->{ip_hash}->{$ip}++;
ba46c7
 			if ($_ =~ /conn= *([0-9]+)/i ){ 
ba46c7
 				if ($exc ne "yes"){	
ba46c7
-					writeFile($CONN_HASH, "$1 $ip");
ba46c7
+					$hashes->{conn_hash}->{$1} = $ip;
ba46c7
 				}
ba46c7
 			}
ba46c7
 		}
ba46c7
@@ -1995,12 +1933,12 @@ sub parseLineNormal
ba46c7
 				$exc = "no";
ba46c7
 				$ip = getIPfromConn($1);
ba46c7
 				if ($ip eq ""){$ip = "Unknown_Host";}
ba46c7
-				for ($xxx = 0; $xxx <= $#excludeIP; $xxx++){
ba46c7
+				for (my $xxx = 0; $xxx < $#excludeIP; $xxx++){
ba46c7
 					if ($ip eq $excludeIP[$xxx]){$exc = "yes";}
ba46c7
 				}
ba46c7
 				if ($exc ne "yes"){
ba46c7
-					writeFile($IP_HASH, "$ip A1");
ba46c7
-					writeFile($CONNCOUNT, "A1");
ba46c7
+					$hashes->{A1}->{$ip}++;
ba46c7
+					$hashes->{conncount}->{"A1"}++;
ba46c7
 					$connCodeCount++;
ba46c7
 				}
ba46c7
 			}
ba46c7
@@ -2010,12 +1948,12 @@ sub parseLineNormal
ba46c7
 				$exc = "no";
ba46c7
 				$ip = getIPfromConn($1);
ba46c7
 				if ($ip eq ""){$ip = "Unknown_Host";}
ba46c7
-				for ($xxx = 0; $xxx <= $#excludeIP; $xxx++){
ba46c7
+				for (my $xxx = 0; $xxx < $#excludeIP; $xxx++){
ba46c7
 				        if ($ip eq $excludeIP[$xxx]){$exc = "yes";}
ba46c7
 				}
ba46c7
 				if ($exc ne "yes"){
ba46c7
-					writeFile($IP_HASH, "$ip B1");
ba46c7
-					writeFile($CONNCOUNT, "B1");
ba46c7
+					$hashes->{B1}->{$ip}++;
ba46c7
+					$hashes->{conncount}->{"B1"}++;
ba46c7
 					$connCodeCount++;	
ba46c7
 				}
ba46c7
 			}
ba46c7
@@ -2025,12 +1963,12 @@ sub parseLineNormal
ba46c7
 				$exc = "no";
ba46c7
 				$ip = getIPfromConn($1);
ba46c7
 				if ($ip eq ""){$ip = "Unknown_Host";}
ba46c7
-				for ($xxx = 0; $xxx <= $#excludeIP; $xxx++){
ba46c7
+				for (my $xxx = 0; $xxx < $#excludeIP; $xxx++){
ba46c7
 				        if ($ip eq $excludeIP[$xxx]){$exc = "yes";}
ba46c7
 				}
ba46c7
 				if ($exc ne "yes"){
ba46c7
-					writeFile($IP_HASH, "$ip B4");
ba46c7
-					writeFile($CONNCOUNT, "B4");
ba46c7
+					$hashes->{B4}->{$ip}++;
ba46c7
+					$hashes->{conncount}->{"B4"}++;
ba46c7
 					$connCodeCount++;
ba46c7
 				}
ba46c7
 		    	}
ba46c7
@@ -2040,12 +1978,12 @@ sub parseLineNormal
ba46c7
 				$exc = "no";
ba46c7
 			       	$ip = getIPfromConn($1);
ba46c7
 				if ($ip eq ""){$ip = "Unknown_Host";}
ba46c7
-				for ($xxx = 0; $xxx <= $#excludeIP; $xxx++){
ba46c7
+				for (my $xxx = 0; $xxx < $#excludeIP; $xxx++){
ba46c7
 				        if ($ip eq $excludeIP[$xxx]){$exc = "yes";}
ba46c7
 				}
ba46c7
 				if ($exc ne "yes"){
ba46c7
-					writeFile($IP_HASH, "$ip T1");
ba46c7
-					writeFile($CONNCOUNT, "T1");
ba46c7
+					$hashes->{T1}->{$ip}++;
ba46c7
+					$hashes->{conncount}->{"T1"}++;
ba46c7
 					$connCodeCount++;	
ba46c7
 				}
ba46c7
 			}
ba46c7
@@ -2055,12 +1993,12 @@ sub parseLineNormal
ba46c7
 				$exc = "no"; 
ba46c7
 				$ip = getIPfromConn($1);
ba46c7
 				if ($ip eq ""){$ip = "Unknown_Host";}
ba46c7
-				for ($xxx = 0; $xxx <= $#excludeIP; $xxx++){
ba46c7
+				for (my $xxx = 0; $xxx < $#excludeIP; $xxx++){
ba46c7
 				        if ($ip eq $excludeIP[$xxx]){$exc = "yes";}
ba46c7
 				}
ba46c7
 				if ($exc ne "yes"){
ba46c7
-					writeFile($IP_HASH, "$ip T2");
ba46c7
-					writeFile($CONNCOUNT, "T2");
ba46c7
+					$hashes->{T2}->{$ip}++;
ba46c7
+					$hashes->{conncount}->{"T2"}++;
ba46c7
 					$connCodeCount++;	
ba46c7
 				}
ba46c7
 			}
ba46c7
@@ -2071,12 +2009,12 @@ sub parseLineNormal
ba46c7
 				$ip = getIPfromConn($1);
ba46c7
 				$maxBerSizeCount++;
ba46c7
 				if ($ip eq ""){$ip = "Unknown_Host";}
ba46c7
-				for ($xxx = 0; $xxx <= $#excludeIP; $xxx++){
ba46c7
+				for (my $xxx = 0; $xxx < $#excludeIP; $xxx++){
ba46c7
 				        if ($ip eq $excludeIP[$xxx]){$exc = "yes";}
ba46c7
 				}
ba46c7
 				if ($exc ne "yes"){
ba46c7
-					writeFile($IP_HASH, "$ip B2");
ba46c7
-					writeFile($CONNCOUNT, "B2");
ba46c7
+					$hashes->{B2}->{$ip}++;
ba46c7
+					$hashes->{conncount}->{"B2"}++;
ba46c7
 					$connCodeCount++;	
ba46c7
 				}
ba46c7
 			}
ba46c7
@@ -2086,12 +2024,12 @@ sub parseLineNormal
ba46c7
 				$exc = "no";
ba46c7
 				$ip = getIPfromConn($1);
ba46c7
 				if ($ip eq ""){$ip = "Unknown_Host";}
ba46c7
-				for ($xxx = 0; $xxx <= $#excludeIP; $xxx++){
ba46c7
+				for (my $xxx = 0; $xxx < $#excludeIP; $xxx++){
ba46c7
 				        if ($ip eq $excludeIP[$xxx]){$exc = "yes";}
ba46c7
 				}
ba46c7
 				if ($exc ne "yes"){
ba46c7
-					writeFile($IP_HASH, "$ip B3");
ba46c7
-					writeFile($CONNCOUNT, "B3");
ba46c7
+					$hashes->{B3}->{$ip}++;
ba46c7
+					$hashes->{conncount}->{"B3"}++;
ba46c7
 					$connCodeCount++;	
ba46c7
 				}
ba46c7
 			}
ba46c7
@@ -2101,12 +2039,12 @@ sub parseLineNormal
ba46c7
 				$exc = "no";
ba46c7
 				$ip = getIPfromConn($1);
ba46c7
 				if ($ip eq ""){$ip = "Unknown_Host";}
ba46c7
-				for ($xxx = 0; $xxx <= $#excludeIP; $xxx++){
ba46c7
+				for (my $xxx = 0; $xxx < $#excludeIP; $xxx++){
ba46c7
 				        if ($ip eq $excludeIP[$xxx]){$exc = "yes";}
ba46c7
 				}
ba46c7
 				if ($exc ne "yes"){
ba46c7
-					writeFile($IP_HASH, "$ip R1");
ba46c7
-					writeFile($CONNCOUNT, "R1");
ba46c7
+					$hashes->{R1}->{$ip}++;
ba46c7
+					$hashes->{conncount}->{"R1"}++;
ba46c7
 					$connCodeCount++;
ba46c7
 				}
ba46c7
 			}
ba46c7
@@ -2116,12 +2054,12 @@ sub parseLineNormal
ba46c7
 				$exc = "no";
ba46c7
 				$ip = getIPfromConn($1);
ba46c7
 				if ($ip eq ""){$ip = "Unknown_Host";}
ba46c7
-				for ($xxx = 0; $xxx <= $#excludeIP; $xxx++){
ba46c7
+				for (my $xxx = 0; $xxx < $#excludeIP; $xxx++){
ba46c7
 				        if ($ip eq $excludeIP[$xxx]){$exc = "yes";}
ba46c7
 				}
ba46c7
 				if ($exc ne "yes"){
ba46c7
-					writeFile($IP_HASH, "$ip P1");
ba46c7
-					writeFile($CONNCOUNT, "P1");
ba46c7
+					$hashes->{P1}->{$ip}++;
ba46c7
+					$hashes->{conncount}->{"P1"}++;
ba46c7
 					$connCodeCount++;	
ba46c7
 				}
ba46c7
 			}
ba46c7
@@ -2131,12 +2069,12 @@ sub parseLineNormal
ba46c7
 				$exc = "no";
ba46c7
 				$ip = getIPfromConn($1);
ba46c7
 				if ($ip eq ""){$ip = "Unknown_Host";}
ba46c7
-				for ($xxx = 0; $xxx <= $#excludeIP; $xxx++){
ba46c7
+				for (my $xxx = 0; $xxx < $#excludeIP; $xxx++){
ba46c7
 				        if ($ip eq $excludeIP[$xxx]){$exc = "yes";}
ba46c7
 				}
ba46c7
 				if ($exc ne "yes"){
ba46c7
-					writeFile($IP_HASH, "$ip P2");
ba46c7
-					writeFile($CONNCOUNT, "P2");
ba46c7
+					$hashes->{P2}->{$ip}++;
ba46c7
+					$hashes->{conncount}->{"P2"}++;
ba46c7
 					$connCodeCount++;
ba46c7
 				}
ba46c7
 			}
ba46c7
@@ -2146,12 +2084,12 @@ sub parseLineNormal
ba46c7
 				$exc = "no";
ba46c7
 				$ip = getIPfromConn($1);
ba46c7
 				if ($ip eq ""){$ip = "Unknown_Host";}
ba46c7
-				for ($xxx = 0; $xxx <= $#excludeIP; $xxx++){
ba46c7
+				for (my $xxx = 0; $xxx < $#excludeIP; $xxx++){
ba46c7
 				        if ($ip eq $excludeIP[$xxx]){$exc = "yes";}
ba46c7
 				}
ba46c7
 				if ($exc ne "yes"){
ba46c7
-					writeFile($IP_HASH, "$ip U1");
ba46c7
-					writeFile($CONNCOUNT, "U1");
ba46c7
+					$hashes->{U1}->{$ip}++;
ba46c7
+					$hashes->{conncount}->{"U1"}++;
ba46c7
 					$connCodeCount++;
ba46c7
 				}
ba46c7
 			}
ba46c7
@@ -2162,59 +2100,60 @@ sub parseLineNormal
ba46c7
 		if ($1 ne "0"){ $errorCount++;}
ba46c7
 		else { $successCount++;}
ba46c7
 	}
ba46c7
-	if ($_ =~ /etime= *([0-9.]+)/ ) { writeFile($ETIME, $1); inc_stats_val('etime',$1,$s_stats,$m_stats); }
ba46c7
+	if ($_ =~ /etime= *([0-9.]+)/ ) { $hashes->{etime}->{$1}++; inc_stats_val('etime',$1,$s_stats,$m_stats); }
ba46c7
 	if ($_ =~ / tag=101 / || $_ =~ / tag=111 / || $_ =~ / tag=100 / || $_ =~ / tag=115 /){
ba46c7
-		if ($_ =~ / nentries= *([0-9]+)/i ){ writeFile($NENTRIES, $1); }
ba46c7
+		if ($_ =~ / nentries= *([0-9]+)/i ){ $hashes->{nentries}->{$1}++; }
ba46c7
 	}
ba46c7
 	if (m/objectclass=\*/i || m/objectclass=top/i ){
ba46c7
 		if (m/ scope=2 /){ $objectclassTopCount++;}
ba46c7
 	}
ba46c7
 	if (m/ EXT oid=/){
ba46c7
 		$extopCount++;
ba46c7
-		if ($_ =~ /oid=\" *([0-9\.]+)/i ){ writeFile($OID,$1); }
ba46c7
+		if ($_ =~ /oid=\" *([0-9\.]+)/i ){ $hashes->{oid}->{$1}++; }
ba46c7
 		if ($1 && $1 eq $startTLSoid){$startTLSCount++;}
ba46c7
 		if ($verb eq "yes"){
ba46c7
-		        if ($_ =~ /conn= *([0-9]+)/i){ writeFile($EXT_CONN, $1); }
ba46c7
-			if ($_ =~ /op= *([0-9]+)/i){ writeFile($EXT_OP, $1); }
ba46c7
+		        if ($_ =~ /conn= *([0-9]+)/i){ push @{$arrays->{extconn}}, $1; }
ba46c7
+			if ($_ =~ /op= *([0-9]+)/i){ push @{$arrays->{extop}}, $1; }
ba46c7
 		}
ba46c7
 	}
ba46c7
-	if ($usage =~ /l/ || $verb eq "yes"){
ba46c7
+	if (($usage =~ /l/ || $verb eq "yes") and / SRCH /){
ba46c7
+		my ($filterConn, $filterOp);
ba46c7
 		if (/ SRCH / && / attrs=/ && $_ =~ /filter=\"(.*)\" /i ){
ba46c7
 			$tmpp = $1;
ba46c7
 			$tmpp =~ tr/A-Z/a-z/;
ba46c7
 			$tmpp =~ s/\\22/\"/g;
ba46c7
-			writeFile($FILTER, $tmpp); 
ba46c7
-			$filterVal = $tmpp;
ba46c7
+			$hashes->{filter}->{$tmpp}++;
ba46c7
 			if ($_ =~ /conn= *([0-9]+)/i) { $filterConn = $1; }
ba46c7
 			if ($_ =~ /op= *([0-9]+)/i) { $filterOp = $1; }
ba46c7
 		} elsif (/ SRCH / && $_ =~ /filter=\"(.*)\"/i){
ba46c7
 			$tmpp = $1;
ba46c7
 			$tmpp =~ tr/A-Z/a-z/;
ba46c7
 			$tmpp =~ s/\\22/\"/g;
ba46c7
-			writeFile($FILTER, $tmpp);
ba46c7
-			$filterVal = $tmpp;
ba46c7
+			$hashes->{filter}->{$tmpp}++;
ba46c7
 			if ($_ =~ /conn= *([0-9]+)/i) { $filterConn = $1; }
ba46c7
 			if ($_ =~ /op= *([0-9]+)/i) { $filterOp = $1; }
ba46c7
 		}
ba46c7
 		$filterCount++;
ba46c7
 		if($usage =~ /u/ || $verb eq "yes"){
ba46c7
-			# we noly need this for the unindexed search report
ba46c7
-			writeFile($FILTERINFO, "$filterVal ,, $filterConn ,, $filterOp");
ba46c7
+			# we only need this for the unindexed search report
ba46c7
+			push @{$arrays->{filterval}}, $tmpp;
ba46c7
+			push @{$arrays->{filterconn}}, $filterConn;
ba46c7
+			push @{$arrays->{filterop}}, $filterOp;
ba46c7
 		}
ba46c7
 	}
ba46c7
 	if ($usage =~ /a/ || $verb eq "yes"){
ba46c7
 		if (/ SRCH /   && $_ =~ /base=\"(.*)\" scope/i ){
ba46c7
+			my ($baseConn, $baseOp, $scopeVal, $scopeConn, $scopeOp);
ba46c7
 			if ($1 eq ""){
ba46c7
 				$tmpp = "Root DSE";
ba46c7
 			} else {
ba46c7
 				$tmpp = $1;
ba46c7
 			}
ba46c7
 			$tmpp =~ tr/A-Z/a-z/;
ba46c7
-			writeFile($BASE, $tmpp);
ba46c7
+			$hashes->{base}->{$tmpp}++;
ba46c7
 			#
ba46c7
 			# grab the search bases & scope for potential unindexed searches
ba46c7
 			#
ba46c7
-			$baseVal = $tmpp;
ba46c7
 			if ($_ =~ /scope= *([0-9]+)/i) { 
ba46c7
 				$scopeVal = $1; 
ba46c7
 			}
ba46c7
@@ -2227,9 +2166,13 @@ sub parseLineNormal
ba46c7
 				$scopeOp = $1;
ba46c7
 			}
ba46c7
 			if($usage =~ /u/ || $verb eq "yes"){
ba46c7
-				# we noly need this for the unindexed search report
ba46c7
-				writeFile($BASEINFO, "$baseVal ,, $baseConn ,, $baseOp");
ba46c7
-				writeFile($SCOPEINFO, "$scopeVal ,, $scopeConn ,, $scopeOp");
ba46c7
+				# we only need this for the unindexed search report
ba46c7
+				push @{$arrays->{baseval}}, $tmpp;
ba46c7
+				push @{$arrays->{baseconn}}, $baseConn;
ba46c7
+				push @{$arrays->{baseop}}, $baseOp;
ba46c7
+				push @{$arrays->{scopeval}}, $scopeVal;
ba46c7
+				push @{$arrays->{scopeconn}}, $scopeConn;
ba46c7
+				push @{$arrays->{scopeop}}, $scopeOp;
ba46c7
 			}
ba46c7
 			$baseCount++;
ba46c7
 			$scopeCount++;
ba46c7
@@ -2243,26 +2186,26 @@ sub parseLineNormal
ba46c7
 	if ($usage =~ /f/ || $verb eq "yes"){
ba46c7
 		if (/ err=49 tag=/ && / dn=\"/){
ba46c7
 			if ($_ =~ /dn=\"(.*)\"/i ){
ba46c7
-				writeFile($DS6XBADPWD, $1);
ba46c7
+				$hashes->{ds6xbadpwd}->{$1}++;
ba46c7
 			}
ba46c7
 			$ds6x = "true";
ba46c7
 			$badPwdCount++;
ba46c7
 		} elsif (/ err=49 tag=/ ){
ba46c7
 			if ($_ =~ /conn= *([0-9]+)/i ){
ba46c7
-				writeFile($BADPWDCONN, $1);
ba46c7
+				push @{$arrays->{badpwdconn}}, $1;
ba46c7
 				$ip = getIPfromConn($1);
ba46c7
 				$badPwdCount++;
ba46c7
 			}
ba46c7
 			if ($_ =~ /op= *([0-9]+)/i ){
ba46c7
-				writeFile($BADPWDOP, $1);
ba46c7
+				push @{$arrays->{badpwdop}}, $1;
ba46c7
 			}
ba46c7
-			writeFile($BADPWDIP, $ip);
ba46c7
+			push @{$arrays->{badpwdip}}, $ip;
ba46c7
 		}
ba46c7
 	}
ba46c7
 	if (/ BIND / && /method=sasl/i){
ba46c7
 		$saslBindCount++;
ba46c7
-		if ($_ =~ /mech=(.*)/i ){     
ba46c7
-			writeFile($SASLMECH, $1);
ba46c7
+		if ($_ =~ /mech=(.*)/i ){
ba46c7
+			$hashes->{saslmech}->{$1}++;
ba46c7
 		}
ba46c7
 	}
ba46c7
 	if (/ conn=Internal op=-1 / && !/ RESULT err=/){ $internalOpCount++; }
ba46c7
@@ -2414,7 +2357,7 @@ displayBindReport
ba46c7
 
ba46c7
 	print "\nBind Report\n";
ba46c7
 	print "====================================================================\n\n";
ba46c7
-	foreach $bindDN (sort { $bindReport{$a} <=> $bindReport{$b} } keys %bindReport) {
ba46c7
+	foreach my $bindDN (sort { $bindReport{$a} <=> $bindReport{$b} } keys %bindReport) {
ba46c7
 		print("Bind DN: $bindDN\n");
ba46c7
 		print("--------------------------------------------------------------------\n");
ba46c7
 		print("   Client Addresses:\n\n");
ba46c7
@@ -2430,11 +2373,11 @@ displayBindReport
ba46c7
 sub
ba46c7
 printClients
ba46c7
 { 
ba46c7
-	@bindConns = &cleanConns(split(' ', @_[0]));
ba46c7
-	$IPcount = "1";
ba46c7
+	my @bindConns = &cleanConns(split(' ', $_[0]));
ba46c7
+	my $IPcount = "1";
ba46c7
 
ba46c7
-	foreach $ip ( keys %connList ){   # Loop over all the IP addresses
ba46c7
-		foreach $bc (@bindConns){ # Loop over each bind conn number and compare it 
ba46c7
+	foreach my $ip ( keys %connList ){   # Loop over all the IP addresses
ba46c7
+		foreach my $bc (@bindConns){ # Loop over each bind conn number and compare it 
ba46c7
 			if($connList{$ip} =~ / $bc /){ 
ba46c7
 				print("        [$IPcount]  $ip\n");
ba46c7
 				$IPcount++;
ba46c7
@@ -2447,22 +2390,22 @@ printClients
ba46c7
 sub
ba46c7
 cleanConns
ba46c7
 {
ba46c7
-	@dirtyConns = @_;
ba46c7
-	$#cleanConns = -1;
ba46c7
-	$c = 0;
ba46c7
+	my @dirtyConns = @_;
ba46c7
+	my @retConns = ();
ba46c7
+	my $c = 0;
ba46c7
 
ba46c7
-	for ($i = 0; $i <=$#dirtyConns; $i++){
ba46c7
+	for (my $i = 0; $i <=$#dirtyConns; $i++){
ba46c7
 		if($dirtyConns[$i] ne ""){
ba46c7
-			$cleanConns[$c++] = $dirtyConns[$i];
ba46c7
+			$retConns[$c++] = $dirtyConns[$i];
ba46c7
 		}
ba46c7
 	}	
ba46c7
-	return @cleanConns;
ba46c7
+	return @retConns;
ba46c7
 }
ba46c7
 
ba46c7
 sub
ba46c7
 printOpStats
ba46c7
 {
ba46c7
-	$dn = @_[0];
ba46c7
+	my $dn = $_[0];
ba46c7
 
ba46c7
 	if( $bindReport{$dn}{"failedBind"} == 0 ){
ba46c7
 		print("        Binds:        " . $bindReport{$dn}{"binds"} . "\n");
ba46c7
@@ -2487,333 +2430,70 @@ printOpStats
ba46c7
 sub
ba46c7
 openFailed
ba46c7
 {
ba46c7
-	$open_error = @_[0];
ba46c7
-	$file_name = @_[1];
ba46c7
-	closeDataFiles();
ba46c7
+	my $open_error = $_[0];
ba46c7
+	my $file_name = $_[1];
ba46c7
 	removeDataFiles();
ba46c7
 	die ("Can not open $file_name error ($open_error)");
ba46c7
 }
ba46c7
 
ba46c7
 sub
ba46c7
-openDataFiles
ba46c7
+openHashFiles
ba46c7
 {
ba46c7
-	# hash files
ba46c7
-	open ($ATTR, ">$ATTR") or do { openFailed($!, $ATTR) };
ba46c7
-	open ($RC, ">$RC") or do { openFailed($!, $RC) };
ba46c7
-	open ($SRC, ">$SRC") or do { openFailed($!, $SRC) };
ba46c7
-	open ($RSRC, ">$RSRC") or do { openFailed($!, $RSRC) };
ba46c7
-	open ($EXCOUNT, ">$EXCOUNT") or do { openFailed($!, $EXCOUNT) };
ba46c7
-	open ($CONN_HASH, ">$CONN_HASH") or do { openFailed($!, $CONN_HASH) };
ba46c7
-	open ($IP_HASH, ">$IP_HASH") or do { openFailed($!, $IP_HASH) };
ba46c7
-	open ($CONNCOUNT, ">$CONNCOUNT") or do { openFailed($!, $CONNCOUNT) };
ba46c7
-	open ($NENTRIES, ">$NENTRIES") or do { openFailed($!, $NENTRIES) };
ba46c7
-	open ($FILTER, ">$FILTER") or do { openFailed($!, $FILTER) };
ba46c7
-	open ($BASE, ">$BASE") or do { openFailed($!, $BASE) };
ba46c7
-	open ($DS6XBADPWD, ">$DS6XBADPWD") or do { openFailed($!, $DS6XBADPWD) };
ba46c7
-	open ($SASLMECH, ">$SASLMECH") or do { openFailed($!, $SASLMECH) };
ba46c7
-	open ($BINDLIST, ">$BINDLIST") or do { openFailed($!, $BINDLIST) };
ba46c7
-	open ($ETIME, ">$ETIME") or do { openFailed($!, $ETIME) };
ba46c7
-	open ($OID, ">$OID") or do { openFailed($!, $OID) };
ba46c7
-
ba46c7
-	# array files
ba46c7
-	open($SRCH_CONN,">$SRCH_CONN") or do { openFailed($!, $SRCH_CONN) };
ba46c7
-	open($SRCH_OP, ">$SRCH_OP") or do { openFailed($!, $SRCH_OP) };
ba46c7
-	open($DEL_CONN, ">$DEL_CONN") or do { openFailed($!, $DEL_CONN) };
ba46c7
-	open($DEL_OP, ">$DEL_OP") or do { openFailed($!, $DEL_OP) };
ba46c7
-	open($MOD_CONN, ">$MOD_CONN") or do { openFailed($!, $MOD_CONN) };
ba46c7
-	open($MOD_OP, ">$MOD_OP") or do { openFailed($!, $MOD_OP) };
ba46c7
-	open($ADD_CONN, ">$ADD_CONN") or do { openFailed($!, $ADD_CONN) };
ba46c7
-	open($ADD_OP, ">$ADD_OP") or do { openFailed($!, $ADD_OP) };
ba46c7
-	open($MODRDN_CONN, ">$MODRDN_CONN") or do { openFailed($!, $MODRDN_CONN) };
ba46c7
-	open($MODRDN_OP, ">$MODRDN_OP") or do { openFailed($!, $MODRDN_OP) };
ba46c7
-	open($CMP_CONN, ">$CMP_CONN") or do { openFailed($!, $CMP_CONN) };
ba46c7
-	open($CMP_OP,">$CMP_OP") or do { openFailed($!, $CMP_OP) };
ba46c7
-	open($TARGET_CONN, ">$TARGET_CONN") or do { openFailed($!, $TARGET_CONN) };
ba46c7
-	open($TARGET_OP, ">$TARGET_OP") or do { openFailed($!, $TARGET_OP) };
ba46c7
-	open($MSGID, ">$MSGID") or do { openFailed($!, $MSGID) };
ba46c7
-	open($BIND_CONN, ">$BIND_CONN") or do { openFailed($!, $BIND_CONN) };
ba46c7
-	open($BIND_OP, ">$BIND_OP") or do { openFailed($!, $BIND_OP) };
ba46c7
-	open($UNBIND_CONN, ">$UNBIND_CONN") or do { openFailed($!, $UNBIND_CONN) };
ba46c7
-	open($UNBIND_OP, ">$UNBIND_OP") or do { openFailed($!, $UNBIND_OP) };
ba46c7
-	open($EXT_CONN, ">$EXT_CONN") or do { openFailed($!, $EXT_CONN) };
ba46c7
-	open($EXT_OP, ">$EXT_OP") or do { openFailed($!, $EXT_OP) };
ba46c7
-	open($NOTES_A_ETIME, ">$NOTES_A_ETIME") or do { openFailed($!, $NOTES_A_ETIME) };
ba46c7
-	open($NOTES_A_CONN, ">$NOTES_A_CONN") or do { openFailed($!, $NOTES_A_CONN) };
ba46c7
-	open($NOTES_A_OP, ">$NOTES_A_OP") or do { openFailed($!, $NOTES_A_OP) };
ba46c7
-	open($NOTES_A_TIME, ">$NOTES_A_TIME") or do { openFailed($!, $NOTES_A_TIME) };
ba46c7
-	open($NOTES_A_NENTRIES, ">$NOTES_A_NENTRIES") or do { openFailed($!, $NOTES_A_NENTRIES) };
ba46c7
-	open($NOTES_U_ETIME, ">$NOTES_U_ETIME") or do { openFailed($!, $NOTES_U_ETIME) };
ba46c7
-	open($NOTES_U_CONN, ">$NOTES_U_CONN") or do { openFailed($!, $NOTES_U_CONN) };
ba46c7
-	open($NOTES_U_OP, ">$NOTES_U_OP") or do { openFailed($!, $NOTES_U_OP) };
ba46c7
-	open($NOTES_U_TIME, ">$NOTES_U_TIME") or do { openFailed($!, $NOTES_U_TIME) };
ba46c7
-	open($NOTES_U_NENTRIES, ">$NOTES_U_NENTRIES") or do { openFailed($!, $NOTES_U_NENTRIES) };
ba46c7
-	open($BADPWDCONN, ">$BADPWDCONN")  or do { openFailed($!, $BADPWDCONN) };
ba46c7
-	open($BADPWDOP, ">$BADPWDOP")  or do { openFailed($!, $BADPWDOP) };
ba46c7
-	open($BADPWDIP, ">$BADPWDIP")  or do { openFailed($!, $NADPWDIP) };
ba46c7
-
ba46c7
-	# info files
ba46c7
-	open($BINDINFO, ">$BINDINFO")  or do { openFailed($!, $BINDINFO) };
ba46c7
-	open($BASEINFO, ">$BASEINFO")  or do { openFailed($!, $BASEINFO) };
ba46c7
-	open($SCOPEINFO, ">$SCOPEINFO")  or do { openFailed($!, $SCOPEINFO) };
ba46c7
-	open($FILTERINFO, ">$FILTERINFO")  or do { openFailed($!, $FILTERINFO) };
ba46c7
-}
ba46c7
-
ba46c7
-sub
ba46c7
-closeDataFiles
ba46c7
-{
ba46c7
-	close $ATTR;
ba46c7
-	close $RC;
ba46c7
-	close $SRC;
ba46c7
-	close $RSRC;
ba46c7
-	close $EXCOUNT;
ba46c7
-	close $CONN_HASH;
ba46c7
-	close $IP_HASH;
ba46c7
-	close $CONNCOUNT;
ba46c7
-	close $NENTRIES;
ba46c7
-	close $FILTER;
ba46c7
-	close $BASE;
ba46c7
-	close $DS6XBADPWD;
ba46c7
-	close $SASLMECH;
ba46c7
-	close $BINDLIST;
ba46c7
-	close $ETIME;
ba46c7
-	close $OID;
ba46c7
-
ba46c7
-	# array files
ba46c7
-	close $SRCH_CONN;
ba46c7
-	close $SRCH_OP;
ba46c7
-	close $DEL_CONN;
ba46c7
-	close $DEL_OP;
ba46c7
-	close $MOD_CONN;
ba46c7
-	close $MOD_OP;
ba46c7
-	close $ADD_CONN;
ba46c7
-	close $ADD_OP;
ba46c7
-	close $MODRDN_CONN;
ba46c7
-	close $MODRDN_OP;
ba46c7
-	close $CMP_CONN;
ba46c7
-	close $CMP_OP;
ba46c7
-	close $TARGET_CONN;
ba46c7
-	close $TARGET_OP;
ba46c7
-	close $MSGID;
ba46c7
-	close $BIND_CONN;
ba46c7
-	close $BIND_OP;
ba46c7
-	close $UNBIND_CONN;
ba46c7
-	close $UNBIND_OP;
ba46c7
-	close $EXT_CONN;
ba46c7
-	close $EXT_OP;
ba46c7
-	close $NOTES_A_ETIME;
ba46c7
-	close $NOTES_A_CONN;
ba46c7
-	close $NOTES_A_OP;
ba46c7
-	close $NOTES_A_TIME;
ba46c7
-	close $NOTES_A_NENTRIES;
ba46c7
-	close $NOTES_U_ETIME;
ba46c7
-	close $NOTES_U_CONN;
ba46c7
-	close $NOTES_U_OP;
ba46c7
-	close $NOTES_U_TIME;
ba46c7
-	close $NOTES_U_NENTRIES;
ba46c7
-	close $BADPWDCONN;
ba46c7
-	close $BADPWDOP;
ba46c7
-	close $BADPWDIP;
ba46c7
-
ba46c7
-	# info files
ba46c7
-	close $BINDINFO;
ba46c7
-	close $BASEINFO;
ba46c7
-	close $SCOPEINFO;
ba46c7
-	close $FILTERINFO;
ba46c7
-}
ba46c7
-
ba46c7
-sub
ba46c7
-removeDataFiles
ba46c7
-{
ba46c7
-	unlink $ATTR;
ba46c7
-	unlink $RC;
ba46c7
-	unlink $SRC;
ba46c7
-	unlink $RSRC;
ba46c7
-	unlink $EXCOUNT;
ba46c7
-	unlink $CONN_HASH;
ba46c7
-	unlink $IP_HASH;
ba46c7
-	unlink $CONNCOUNT;
ba46c7
-	unlink $NENTRIES;
ba46c7
-	unlink $FILTER;
ba46c7
-	unlink $BASE;
ba46c7
-	unlink $DS6XBADPWD;
ba46c7
-	unlink $SASLMECH;
ba46c7
-	unlink $BINDLIST;
ba46c7
-	unlink $ETIME;
ba46c7
-	unlink $OID;
ba46c7
-
ba46c7
-	# array files
ba46c7
-	unlink $SRCH_CONN;
ba46c7
-	unlink $SRCH_OP;
ba46c7
-	unlink $DEL_CONN;
ba46c7
-	unlink $DEL_OP;
ba46c7
-	unlink $MOD_CONN;
ba46c7
-	unlink $MOD_OP;
ba46c7
-	unlink $ADD_CONN;
ba46c7
-	unlink $ADD_OP;
ba46c7
-	unlink $MODRDN_CONN;
ba46c7
-	unlink $MODRDN_OP;
ba46c7
-	unlink $CMP_CONN;
ba46c7
-	unlink $CMP_OP;
ba46c7
-	unlink $TARGET_CONN;
ba46c7
-	unlink $TARGET_OP;
ba46c7
-	unlink $MSGID;
ba46c7
-	unlink $BIND_CONN;
ba46c7
-	unlink $BIND_OP;
ba46c7
-	unlink $UNBIND_CONN;
ba46c7
-	unlink $UNBIND_OP;
ba46c7
-	unlink $EXT_CONN;
ba46c7
-	unlink $EXT_OP;
ba46c7
-	unlink $NOTES_A_ETIME;
ba46c7
-	unlink $NOTES_A_CONN;
ba46c7
-	unlink $NOTES_A_OP;
ba46c7
-	unlink $NOTES_A_TIME;
ba46c7
-	unlink $NOTES_A_NENTRIES;
ba46c7
-	unlink $NOTES_U_ETIME;
ba46c7
-	unlink $NOTES_U_CONN;
ba46c7
-	unlink $NOTES_U_OP;
ba46c7
-	unlink $NOTES_U_TIME;
ba46c7
-	unlink $NOTES_U_NENTRIES;
ba46c7
-	unlink $BADPWDCONN;
ba46c7
-	unlink $BADPWDOP;
ba46c7
-	unlink $BADPWDIP;
ba46c7
-
ba46c7
-	# info files
ba46c7
-	unlink $BINDINFO;
ba46c7
-	unlink $BASEINFO;
ba46c7
-	unlink $SCOPEINFO;
ba46c7
-	unlink $FILTERINFO;
ba46c7
-}
ba46c7
-
ba46c7
-sub
ba46c7
-getIPfromConn
ba46c7
-{
ba46c7
-	$connip = @_[0];
ba46c7
-	$retval = "";
ba46c7
-
ba46c7
-	close $CONN_HASH; # we can not read the file is its already open
ba46c7
-	open(CONN,"$CONN_HASH") or do { openFailed($!, $CONN_HASH) };
ba46c7
-	while (<CONN>){
ba46c7
-		if($_ =~ /$connip (.*)/){
ba46c7
-			$retval = $1;
ba46c7
-			last;
ba46c7
-		}
ba46c7
+	my $dir = shift;
ba46c7
+	my %hashes = ();
ba46c7
+	for my $hn (@_) {
ba46c7
+		my %h = (); # using my in inner loop will create brand new hash every time through for tie
ba46c7
+		my $fn = "$dir/$hn.logconv.db";
ba46c7
+		push @removefiles, $fn;
ba46c7
+		tie %h, "DB_File", $fn, O_CREAT|O_RDWR, 0600, $DB_HASH or do { openFailed($!, $fn) };
ba46c7
+		$hashes{$hn} = \%h;
ba46c7
 	}
ba46c7
-	close CONN;
ba46c7
-	#reopen file for writing(append)
ba46c7
-	open($CONN_HASH,">>$CONN_HASH") or do { openFailed($!, $CONN_HASH) };
ba46c7
-
ba46c7
-	return $retval;
ba46c7
-}
ba46c7
-
ba46c7
-sub
ba46c7
-writeFile
ba46c7
-{
ba46c7
-	$file = @_[0];
ba46c7
-	$text = @_[1] . "\n";
ba46c7
-
ba46c7
-	print $file $text;
ba46c7
+	return \%hashes;
ba46c7
 }
ba46c7
 
ba46c7
-# This hash file stores one value per line
ba46c7
 sub
ba46c7
-getCounterHashFromFile
ba46c7
+openArrayFiles
ba46c7
 {
ba46c7
-	$file = @_[0];
ba46c7
-	my %hash = ();
ba46c7
-
ba46c7
-	open(FILE,"$file") or do { openFailed($!, $file) };
ba46c7
-	while(<FILE>){
ba46c7
-		chomp;
ba46c7
-		$hash{$_}++;
ba46c7
+	my $dir = shift;
ba46c7
+	my %arrays = ();
ba46c7
+	for my $an (@_) {
ba46c7
+		my @ary = (); # using my in inner loop will create brand new array every time through for tie
ba46c7
+		my $fn = "$dir/$an.logconv.db";
ba46c7
+		push @removefiles, $fn;
ba46c7
+		tie @ary, "DB_File", $fn, O_CREAT|O_RDWR, 0600, $DB_RECNO or do { openFailed($!, $fn) };
ba46c7
+		$arrays{$an} = \@ary;
ba46c7
 	}
ba46c7
-	close FILE;
ba46c7
-
ba46c7
-	return %hash;
ba46c7
+	return \%arrays;
ba46c7
 }
ba46c7
 
ba46c7
-# this hash file stores two values per line (2 dimension hash)
ba46c7
 sub
ba46c7
-getTwoDimHashFromFile
ba46c7
+removeDataFiles
ba46c7
 {
ba46c7
-	$file = @_[0];
ba46c7
-	my %hash = ();
ba46c7
+    if (!$needCleanup) { return ; }
ba46c7
 
ba46c7
-	open(FILE,"$file") or do { openFailed($!, $file) };
ba46c7
-	while(<FILE>){
ba46c7
-		@parts = split (' ', $_);
ba46c7
-		chomp(@parts);
ba46c7
-		$hash{$parts[0]}{$parts[1]}++;
ba46c7
+	for my $h (keys %{$hashes}) {
ba46c7
+		untie %{$hashes->{$h}};
ba46c7
 	}
ba46c7
-	close FILE;
ba46c7
-
ba46c7
-	return %hash;
ba46c7
-}
ba46c7
-
ba46c7
-# this hash file stores two values per line (1 dimension hash)
ba46c7
-sub
ba46c7
-getHashFromFile
ba46c7
-{
ba46c7
-	$file = @_[0];
ba46c7
-	my %hash = ();
ba46c7
-	@parts = ();
ba46c7
-
ba46c7
-	open(FILE,"$file") or do { openFailed($!, $file ) };
ba46c7
-	while(<FILE>){
ba46c7
-		@parts = split (' ',$_);
ba46c7
-		chomp(@parts);
ba46c7
-		$hash{$parts[0]} = $parts[1];
ba46c7
+	for my $a (keys %{$arrays}) {
ba46c7
+		untie @{$arrays->{$a}};
ba46c7
 	}
ba46c7
-	close FILE;
ba46c7
-
ba46c7
-	return %hash;
ba46c7
-}
ba46c7
-
ba46c7
-# Return array of values from the file
ba46c7
-sub
ba46c7
-getArrayFromFile
ba46c7
-{
ba46c7
-	my @arry;
ba46c7
-	$file = @_[0];
ba46c7
-	$array_count = 0;
ba46c7
-
ba46c7
-	open(FILE,"$file") or do { openFailed($!, $file) };
ba46c7
-	while(<FILE>){
ba46c7
-		chomp;
ba46c7
-		$arry[$array_count] = $_;
ba46c7
-		$array_count++;
ba46c7
+	for my $file (@removefiles) {
ba46c7
+		unlink $file;
ba46c7
 	}
ba46c7
-	close FILE;
ba46c7
-
ba46c7
-	return @arry;
ba46c7
+    $needCleanup = 0;
ba46c7
 }
ba46c7
 
ba46c7
-# build the three array
ba46c7
+END { print "Cleaning up temp files . . .\n"; removeDataFiles(); print "Done\n"; }
ba46c7
+
ba46c7
 sub
ba46c7
-getInfoArraysFromFile
ba46c7
+getIPfromConn
ba46c7
 {
ba46c7
-	$file = @_[0];
ba46c7
-	$array_count = 0;
ba46c7
-	@parts = ();
ba46c7
-
ba46c7
-	open(FILE,"<$file") or do { openFailed($!, $file) };
ba46c7
-	while(<FILE>){
ba46c7
-		@parts = split (' ,, ',$_);
ba46c7
-		chomp(@parts);
ba46c7
-		if($#parts > 0){
ba46c7
-			$fileArray1[$array_count] = $parts[0];
ba46c7
-			$fileArray2[$array_count] = $parts[1];
ba46c7
-			$fileArray3[$array_count] = $parts[2];
ba46c7
-			$array_count++;
ba46c7
-		}
ba46c7
-	}
ba46c7
-	close FILE;
ba46c7
+	my $connid = shift;
ba46c7
+	return $hashes->{conn_hash}->{$connid};
ba46c7
 }
ba46c7
 
ba46c7
-
ba46c7
-
ba46c7
 #######################################
ba46c7
 #                                     #
ba46c7
 #             The  End                #
ba46c7
 #                                     #
ba46c7
 #######################################
ba46c7
-
ba46c7
-- 
ba46c7
1.7.1
ba46c7