ldap/admin/src/logconv.pl | 2082 ++++++++++++-----------------
ldap/servers/slapd/back-ldbm/ldbm_search.c | 6
ldap/servers/slapd/result.c | 3
ldap/servers/slapd/slapi-plugin.h | 1
man/man1/logconv.pl.1 | 10
5 files changed, 940 insertions(+), 1162 deletions(-)
New commits:
commit e38685be139c2420cc969499324405a30203122a
Author: Rich Megginson <rmeggins(a)redhat.com>
Date: Fri Sep 27 11:08:29 2013 -0600
Ticket 47533 logconv: some stats do not work across server restarts
https://fedorahosted.org/389/ticket/47533
Reviewed by: mreynolds (Thanks!)
Branch: master
Fix Description: Most of the stat hashes use connid,opid as the hash key.
The connid,opid are not unique because the server recycles connection ids
when the server restarts. The solution is to use a triplet of
$serverRestartCount,$connid,$opid
as the hash key. This uniquely identifies a particular log event over
restarts. There is also some additional cleanup that needs to be done when
the server is reset - returning fds, marking connections as closed, etc.
Also fixed some gmtime handling - we were doing too many conversions.
This fix adds another command line option - -U - for a summary of search
filters which are unindexed or have unindexed components. The full detailed
report is just too much data.
Platforms tested: RHEL6 x86_64
Flag Day: no
Doc impact: no
(cherry picked from commit 92ac8f48c1e5a8a049f4cfd1912fd570c628408f)
diff --git a/ldap/admin/src/logconv.pl b/ldap/admin/src/logconv.pl
index ca07a3a..275ce34 100755
--- a/ldap/admin/src/logconv.pl
+++ b/ldap/admin/src/logconv.pl
@@ -86,7 +86,8 @@ my $xi = 0;
my $bindReportDN;
my $usage = "";
my @latency;
-my @openConnection;
+# key is conn number - val is IP address
+my %openConnection;
my @errorCode;
my @errtext;
my @errornum;
@@ -133,7 +134,8 @@ GetOptions(
'u' => sub { $usage = $usage . "u"; },
'r' => sub { $usage = $usage . "r"; },
'y' => sub { $usage = $usage . "y"; },
- 'p' => sub { $usage = $usage . "p"; }
+ 'p' => sub { $usage = $usage . "p"; },
+ 'U' => sub { $usage = $usage . "U"; }
);
#
@@ -657,7 +659,7 @@ print "Paged Searches: $pagedSearchCount\n";
print "Unindexed Searches: $unindexedSrchCountNotesA\n";
print "Unindexed Components: $unindexedSrchCountNotesU\n";
-if ($verb eq "yes" || $usage =~ /u/){
+if ($verb eq "yes" || $usage =~ /u/ || $usage =~ /U/){
if ($unindexedSrchCountNotesA > 0){
my $conn_hash = $hashes->{conn_hash};
my $notesa_conn_op = $hashes->{notesa_conn_op};
@@ -670,28 +672,39 @@ if ($verb eq "yes" || $usage =~ /u/){
my $notesCount = 1;
my $unindexedIp;
- while (my ($conn_op, $count) = each %{$notesa_conn_op}) {
- my ($conn, $op) = split(",", $conn_op);
- if (exists($conn_hash->{$conn}) && defined($conn_hash->{$conn})) {
- $unindexedIp = $conn_hash->{$conn};
- } else {
- $unindexedIp = "?";
- }
- print "\n Unindexed Components #".$notesCount."\n";
$notesCount++;
- print " - Date/Time: $time_conn_op->{$conn_op}\n";
- print " - Connection Number: $conn\n";
- print " - Operation Number: $op\n";
- print " - Etime: $etime_conn_op->{$conn_op}\n";
- print " - Nentries: $nentries_conn_op->{$conn_op}\n";
- print " - IP Address: $unindexedIp\n";
- if (exists($base_conn_op->{$conn_op}) &&
defined($base_conn_op->{$conn_op})) {
- print " - Search Base: $base_conn_op->{$conn_op}\n";
+ my %uniqFilt = (); # hash of unique filters
+ while (my ($srcnt_conn_op, $count) = each %{$notesa_conn_op}) {
+ my ($srvRstCnt, $conn, $op) = split(",", $srcnt_conn_op);
+ $unindexedIp = getIPfromConn($conn, $srvRstCnt);
+ if ($usage =~ /u/) {
+ print "\n Unindexed Search #".$notesCount."\n";
+ print " - Date/Time: $time_conn_op->{$srcnt_conn_op}\n";
+ print " - Connection Number: $conn\n";
+ print " - Operation Number: $op\n";
+ print " - Etime: $etime_conn_op->{$srcnt_conn_op}\n";
+ print " - Nentries:
$nentries_conn_op->{$srcnt_conn_op}\n";
+ print " - IP Address: $unindexedIp\n";
+ if (exists($base_conn_op->{$srcnt_conn_op}) &&
defined($base_conn_op->{$srcnt_conn_op})) {
+ print " - Search Base: $base_conn_op->{$srcnt_conn_op}\n";
+ }
+ if (exists($scope_conn_op->{$srcnt_conn_op}) &&
defined($scope_conn_op->{$srcnt_conn_op})) {
+ print " - Search Scope:
$scope_conn_op->{$srcnt_conn_op}\n";
+ }
}
- if (exists($scope_conn_op->{$conn_op}) &&
defined($scope_conn_op->{$conn_op})) {
- print " - Search Scope: $scope_conn_op->{$conn_op}\n";
+ if (exists($filter_conn_op->{$srcnt_conn_op}) &&
defined($filter_conn_op->{$srcnt_conn_op})) {
+ if ($usage =~ /u/) {
+ print " - Search Filter:
$filter_conn_op->{$srcnt_conn_op}\n";
+ }
+ $uniqFilt{$filter_conn_op->{$srcnt_conn_op}}++;
}
- if (exists($filter_conn_op->{$conn_op}) &&
defined($filter_conn_op->{$conn_op})) {
- print " - Search Filter: $filter_conn_op->{$conn_op}\n";
+ $notesCount++;
+ }
+ if ($usage =~ /U/) {
+ print "\n Unindexed Search Summary - $notesCount total unindexed
searches\n";
+ foreach my $key (sort { $uniqFilt{$b} <=> $uniqFilt{$a} } keys %uniqFilt) {
+ if ($uniqFilt{$key} > 0) {
+ printf " - Number of times used unindexed: %10d Filter: $key\n",
$uniqFilt{$key};
+ }
}
}
}
@@ -707,28 +720,39 @@ if ($verb eq "yes" || $usage =~ /u/){
my $notesCount = 1;
my $unindexedIp;
- while (my ($conn_op, $count) = each %{$notesu_conn_op}) {
- my ($conn, $op) = split(",", $conn_op);
- if (exists($conn_hash->{$conn}) && defined($conn_hash->{$conn})) {
- $unindexedIp = $conn_hash->{$conn};
- } else {
- $unindexedIp = "?";
- }
- print "\n Unindexed Components #".$notesCount."\n";
$notesCount++;
- print " - Date/Time: $time_conn_op->{$conn_op}\n";
- print " - Connection Number: $conn\n";
- print " - Operation Number: $op\n";
- print " - Etime: $etime_conn_op->{$conn_op}\n";
- print " - Nentries: $nentries_conn_op->{$conn_op}\n";
- print " - IP Address: $unindexedIp\n";
- if (exists($base_conn_op->{$conn_op}) &&
defined($base_conn_op->{$conn_op})) {
- print " - Search Base: $base_conn_op->{$conn_op}\n";
+ my %uniqFilt = (); # hash of unique filters
+ while (my ($srcnt_conn_op, $count) = each %{$notesu_conn_op}) {
+ my ($srvRstCnt, $conn, $op) = split(",", $srcnt_conn_op);
+ $unindexedIp = getIPfromConn($conn, $srvRstCnt);
+ if ($usage =~ /u/) {
+ print "\n Unindexed Component #".$notesCount."\n";
+ print " - Date/Time: $time_conn_op->{$srcnt_conn_op}\n";
+ print " - Connection Number: $conn\n";
+ print " - Operation Number: $op\n";
+ print " - Etime: $etime_conn_op->{$srcnt_conn_op}\n";
+ print " - Nentries:
$nentries_conn_op->{$srcnt_conn_op}\n";
+ print " - IP Address: $unindexedIp\n";
+ if (exists($base_conn_op->{$srcnt_conn_op}) &&
defined($base_conn_op->{$srcnt_conn_op})) {
+ print " - Search Base: $base_conn_op->{$srcnt_conn_op}\n";
+ }
+ if (exists($scope_conn_op->{$srcnt_conn_op}) &&
defined($scope_conn_op->{$srcnt_conn_op})) {
+ print " - Search Scope:
$scope_conn_op->{$srcnt_conn_op}\n";
+ }
}
- if (exists($scope_conn_op->{$conn_op}) &&
defined($scope_conn_op->{$conn_op})) {
- print " - Search Scope: $scope_conn_op->{$conn_op}\n";
+ if (exists($filter_conn_op->{$srcnt_conn_op}) &&
defined($filter_conn_op->{$srcnt_conn_op})) {
+ if ($usage =~ /u/) {
+ print " - Search Filter:
$filter_conn_op->{$srcnt_conn_op}\n";
+ }
+ $uniqFilt{$filter_conn_op->{$srcnt_conn_op}}++;
}
- if (exists($filter_conn_op->{$conn_op}) &&
defined($filter_conn_op->{$conn_op})) {
- print " - Search Filter: $filter_conn_op->{$conn_op}\n";
+ $notesCount++;
+ }
+ if ($usage =~ /U/) {
+ print "\n Unindexed Component Summary - $notesCount total unindexed
components\n";
+ foreach my $key (sort { $uniqFilt{$b} <=> $uniqFilt{$a} } keys %uniqFilt) {
+ if ($uniqFilt{$key} > 0) {
+ printf " - Number of times used unindexed: %10d Filter: $key\n",
$uniqFilt{$key};
+ }
}
}
}
@@ -829,12 +853,10 @@ if ($verb eq "yes" || $usage =~ /y/){
###################################
if ($verb eq "yes" || $usage =~ /p/){
- if (@openConnection > 0){
+ if (%openConnection){
print "\n\n----- Current Open Connection IDs ----- \n\n";
- for (my $i=0; $i <= $#openConnection ; $i++) {
- if ($openConnection[$i]) {
- print "Conn Number: $i (" . getIPfromConn($i) . ")\n";
- }
+ while (my ($connid, $ip) = each %openConnection) {
+ print "Conn Number: $connid ($ip)\n";
}
}
}
@@ -904,13 +926,13 @@ if ($verb eq "yes" || $usage =~ /f/ ){
my $badpwd_conn_op = $hashes->{badpwd_conn_op};
# key is binddn - val is count
my %badPassword = ();
- my @badPasswordIp = ();
- while (my ($conn_op, $count) = each %{$badpwd_conn_op}) {
- my ($conn, $op) = split(",", $conn_op);
- if (exists($bind_conn_op->{$conn_op}) &&
defined($bind_conn_op->{$conn_op})) {
- my $binddn = $bind_conn_op->{$conn_op};
+ my %badPasswordIp = ();
+ while (my ($srcnt_conn_op, $ip) = each %{$badpwd_conn_op}) {
+ my ($srvRstCnt, $conn, $op) = split(",", $srcnt_conn_op);
+ if (exists($bind_conn_op->{$srcnt_conn_op}) &&
defined($bind_conn_op->{$srcnt_conn_op})) {
+ my $binddn = $bind_conn_op->{$srcnt_conn_op};
$badPassword{$binddn}++;
- push @badPasswordIp, getIPfromConn($conn);
+ $badPasswordIp{$ip}++;
}
}
# sort the new hash of $badPassword{}
@@ -923,8 +945,11 @@ if ($verb eq "yes" || $usage =~ /f/ ){
printf "%-4s %-40s\n", $badPassword{"$badpw"}, $badpw;
}
print "\nFrom the IP address(s) :\n\n";
- for (my $i=0; $i<$badPwdCount; $i++) {
- print "\t\t$badPasswordIp[$i]\n";
+ $bpCount = 0;
+ foreach my $ip (sort {$badPassword{$b} <=> $badPassword{$a} } keys
%badPasswordIp){
+ if ($bpCount > $sizeCount){ last;}
+ $bpCount++;
+ printf "%-4s %-16s\n", $badPasswordIp{$ip}, $ip;
}
if ($bpTotal > $badPwdCount){
print "\n** Warning : Wrongly reported failed login attempts : ". ($bpTotal
- $badPwdCount) . "\n";
@@ -1220,33 +1245,28 @@ if ($usage =~ /g/i || $verb eq "yes"){
print "\n\n----- Abandon Request Stats -----\n\n";
- while (my ($conn_op, $targ_msgid) = each %{$abandon_conn_op}) {
- my ($conn, $op) = split(",", $conn_op);
+ while (my ($srcnt_conn_op, $targ_msgid) = each %{$abandon_conn_op}) {
+ my ($srvRstCnt, $conn, $op) = split(",", $srcnt_conn_op);
my ($targetop, $msgid) = split(",", $targ_msgid);
- my $conn_targ = "$conn,$targetop";
- my $clientIP;
- if (exists($conn_hash->{$conn}) && defined($conn_hash->{$conn})) {
- $clientIP = $conn_hash->{$conn};
- } else {
- $clientIP = "Unknown";
- }
- if (exists($srch_conn_op->{$conn_targ}) &&
defined($srch_conn_op->{$conn_targ})) {
+ my $srcnt_conn_targ = "$srvRstCnt,$conn,$targetop";
+ my $clientIP = getIPfromConn($conn, $srvRstCnt);
+ if (exists($srch_conn_op->{$srcnt_conn_targ}) &&
defined($srch_conn_op->{$srcnt_conn_targ})) {
print " - SRCH conn=$conn op=$targetop msgid=$msgid client=$clientIP\n";
- } elsif (exists($del_conn_op->{$conn_targ}) &&
defined($del_conn_op->{$conn_targ})) {
+ } elsif (exists($del_conn_op->{$srcnt_conn_targ}) &&
defined($del_conn_op->{$srcnt_conn_targ})) {
print " - DEL conn=$conn op=$targetop msgid=$msgid client=$clientIP\n";
- } elsif (exists($add_conn_op->{$conn_targ}) &&
defined($add_conn_op->{$conn_targ})) {
+ } elsif (exists($add_conn_op->{$srcnt_conn_targ}) &&
defined($add_conn_op->{$srcnt_conn_targ})) {
print " - ADD conn=$conn op=$targetop msgid=$msgid client=$clientIP\n";
- } elsif (exists($mod_conn_op->{$conn_targ}) &&
defined($mod_conn_op->{$conn_targ})) {
+ } elsif (exists($mod_conn_op->{$srcnt_conn_targ}) &&
defined($mod_conn_op->{$srcnt_conn_targ})) {
print " - MOD conn=$conn op=$targetop msgid=$msgid client=$clientIP\n";
- } elsif (exists($cmp_conn_op->{$conn_targ}) &&
defined($cmp_conn_op->{$conn_targ})) {
+ } elsif (exists($cmp_conn_op->{$srcnt_conn_targ}) &&
defined($cmp_conn_op->{$srcnt_conn_targ})) {
print " - CMP conn=$conn op=$targetop msgid=$msgid client=$clientIP\n";
- } elsif (exists($mdn_conn_op->{$conn_targ}) &&
defined($mdn_conn_op->{$conn_targ})) {
+ } elsif (exists($mdn_conn_op->{$srcnt_conn_targ}) &&
defined($mdn_conn_op->{$srcnt_conn_targ})) {
print " - MODRDN conn=$conn op=$targetop msgid=$msgid client=$clientIP\n";
- } elsif (exists($bind_conn_op->{$conn_targ}) &&
defined($bind_conn_op->{$conn_targ})) {
+ } elsif (exists($bind_conn_op->{$srcnt_conn_targ}) &&
defined($bind_conn_op->{$srcnt_conn_targ})) {
print " - BIND conn=$conn op=$targetop msgid=$msgid client=$clientIP\n";
- } elsif (exists($unbind_conn_op->{$conn_targ}) &&
defined($unbind_conn_op->{$conn_targ})) {
+ } elsif (exists($unbind_conn_op->{$srcnt_conn_targ}) &&
defined($unbind_conn_op->{$srcnt_conn_targ})) {
print " - UNBIND conn=$conn op=$targetop msgid=$msgid client=$clientIP\n";
- } elsif (exists($ext_conn_op->{$conn_targ}) &&
defined($ext_conn_op->{$conn_targ})) {
+ } elsif (exists($ext_conn_op->{$srcnt_conn_targ}) &&
defined($ext_conn_op->{$srcnt_conn_targ})) {
print " - EXT conn=$conn op=$targetop msgid=$msgid client=$clientIP\n";
} else {
print " - UNKNOWN conn=$conn op=$targetop msgid=$msgid
client=$clientIP\n";
@@ -1521,6 +1541,44 @@ processOpForBindReport
}
my ($last_tm, $lastzone, $last_min, $gmtime, $tzoff);
+sub handleConnClose
+{
+ my $connID = shift;
+ $fdReturned++;
+ $simConnection--;
+
+ delete $openConnection{$connID};
+ if ($reportStats or ($verb eq "yes") || ($usage =~ /y/)) {
+ # if we didn't see the start time of this connection
+ # i.e. due to truncation or log rotation
+ # then just set to 0
+ my $stoc = $hashes->{start_time_of_connection}->{$connID} || 0;
+ $hashes->{end_time_of_connection}->{$connID} = $gmtime || 0;
+ my $diff = $hashes->{end_time_of_connection}->{$connID} - $stoc;
+ $hashes->{start_time_of_connection}->{$connID} =
$hashes->{end_time_of_connection}->{$connID} = 0;
+ if ($diff <= 1) { $latency[0]++;}
+ if ($diff == 2) { $latency[1]++;}
+ if ($diff == 3) { $latency[2]++;}
+ if ($diff >= 4 && $diff <=5 ) { $latency[3]++;}
+ if ($diff >= 6 && $diff <=10 ) { $latency[4]++;}
+ if ($diff >= 11 && $diff <=15 ) { $latency[5]++;}
+ if ($diff >= 16) { $latency[6] ++;}
+ }
+}
+
+sub handleRestart
+{
+ # there are some stats which depend on restarts
+ if ($verb eq "yes") {
+ print "Found a restart - resetting stats that depend on restarts";
+ }
+ for my $connID (keys %openConnection) {
+ handleConnClose($connID);
+ }
+ %openConnection = (); # reset open connections
+ $serverRestartCount++;
+}
+
sub parseLineNormal
{
local $_ = $logline;
@@ -1612,42 +1670,42 @@ sub parseLineNormal
$anyAttrs++;
}
if ($verb eq "yes"){
- if ($_ =~ /conn= *([0-9A-Z]+) +op= *([0-9\-]+)/i){
$hashes->{srch_conn_op}->{"$1,$2"}++;}
+ if ($_ =~ /conn= *([0-9A-Z]+) +op= *([0-9\-]+)/i){
$hashes->{srch_conn_op}->{"$serverRestartCount,$1,$2"}++;}
}
}
if (m/ DEL/){
$delCount++;
if($reportStats){ inc_stats('del',$s_stats,$m_stats); }
if ($verb eq "yes"){
- if ($_ =~ /conn= *([0-9A-Z]+) +op= *([0-9\-]+)/i){
$hashes->{del_conn_op}->{"$1,$2"}++;}
+ if ($_ =~ /conn= *([0-9A-Z]+) +op= *([0-9\-]+)/i){
$hashes->{del_conn_op}->{"$serverRestartCount,$1,$2"}++;}
}
}
if (m/ MOD dn=/){
$modCount++;
if($reportStats){ inc_stats('mod',$s_stats,$m_stats); }
if ($verb eq "yes"){
- if ($_ =~ /conn= *([0-9A-Z]+) +op= *([0-9\-]+)/i){
$hashes->{mod_conn_op}->{"$1,$2"}++;}
+ if ($_ =~ /conn= *([0-9A-Z]+) +op= *([0-9\-]+)/i){
$hashes->{mod_conn_op}->{"$serverRestartCount,$1,$2"}++;}
}
}
if (m/ ADD/){
$addCount++;
if($reportStats){ inc_stats('add',$s_stats,$m_stats); }
if ($verb eq "yes"){
- if ($_ =~ /conn= *([0-9A-Z]+) +op= *([0-9\-]+)/i){
$hashes->{add_conn_op}->{"$1,$2"}++;}
+ if ($_ =~ /conn= *([0-9A-Z]+) +op= *([0-9\-]+)/i){
$hashes->{add_conn_op}->{"$serverRestartCount,$1,$2"}++;}
}
}
if (m/ MODRDN/){
$modrdnCount++;
if($reportStats){ inc_stats('modrdn',$s_stats,$m_stats); }
if ($verb eq "yes"){
- if ($_ =~ /conn= *([0-9A-Z]+) +op= *([0-9\-]+)/i){
$hashes->{mdn_conn_op}->{"$1,$2"}++;}
+ if ($_ =~ /conn= *([0-9A-Z]+) +op= *([0-9\-]+)/i){
$hashes->{mdn_conn_op}->{"$serverRestartCount,$1,$2"}++;}
}
}
if (m/ CMP dn=/){
$cmpCount++;
if($reportStats){ inc_stats('cmp',$s_stats,$m_stats); }
if ($verb eq "yes" || $usage =~ /g/i){
- if ($_ =~ /conn= *([0-9A-Z]+) +op= *([0-9\-]+)/i){
$hashes->{cmp_conn_op}->{"$1,$2"}++;}
+ if ($_ =~ /conn= *([0-9A-Z]+) +op= *([0-9\-]+)/i){
$hashes->{cmp_conn_op}->{"$serverRestartCount,$1,$2"}++;}
}
}
if (m/ ABANDON /){
@@ -1662,7 +1720,7 @@ sub parseLineNormal
if ($_ =~ /conn= *([0-9A-Z]+) +op= *([0-9\-]+) +ABANDON +targetop= *([0-9a-zA-Z]+)
+msgid= *([0-9\-]+)/i ){
# abandon_conn_op - key is the conn,op of the ABANDON request
# the value is the targetop,msgid of the ABANDON request
- $hashes->{abandon_conn_op}->{"$1,$2"} = "$3,$4"; #
targetop,msgid
+ $hashes->{abandon_conn_op}->{"$serverRestartCount,$1,$2"} =
"$3,$4"; # targetop,msgid
}
}
if (m/ VLV /){
@@ -1676,7 +1734,9 @@ sub parseLineNormal
if (m/ SORT /){$vlvSortCount++}
if (m/ version=2/){$v2BindCount++}
if (m/ version=3/){$v3BindCount++}
- if (m/ conn=1 fd=/){$serverRestartCount++}
+ if (m/ conn=1 fd=/){
+ handleRestart();
+ }
if (m/ SSL connection from/){$sslCount++; if($reportStats){
inc_stats('sslconns',$s_stats,$m_stats); }}
if (m/ connection from local to /){$ldapiCount++;}
if($_ =~ /AUTOBIND dn=\"(.*)\"/){
@@ -1697,9 +1757,11 @@ sub parseLineNormal
}
}
if (m/ connection from/){
+ my $ip;
if ($_ =~ /connection from *([0-9A-Fa-f\.\:]+)/i ){
+ $ip = $1;
for (my $xxx =0; $xxx < $#excludeIP; $xxx++){
- if ($excludeIP[$xxx] eq $1){$exc = "yes";}
+ if ($excludeIP[$xxx] eq $ip){$exc = "yes";}
}
if ($exc ne "yes"){
$connectionCount++;
@@ -1711,40 +1773,17 @@ sub parseLineNormal
$maxsimConnection = $simConnection;
}
($connID) = $_ =~ /conn=(\d*)\s/;
- $openConnection[$connID]++;
+ $openConnection{$connID} = $ip;
if ($reportStats or ($verb eq "yes") || ($usage =~ /y/)) {
- my ($time, $tzone) = split (' ', $_);
- my ($date, $hr, $min, $sec) = split (':', $time);
- my ($day, $mon, $yr) = split ('/', $date);
- $day =~ s/\[//;
- $hashes->{start_time_of_connection}->{$connID} = timegm($sec, $min, $hr, $day,
$monthname{$mon}, $yr);
+ $hashes->{start_time_of_connection}->{$connID} = $gmtime;
}
}
if (m/ SSL client bound as /){$sslClientBindCount++;}
if (m/ SSL failed to map client certificate to LDAP DN/){$sslClientFailedCount++;}
if (m/ fd=/ && m/slot=/){$fdTaken++}
if (m/ fd=/ && m/closed/){
- $fdReturned++;
- $simConnection--;
-
($connID) = $_ =~ /conn=(\d*)\s/;
- $openConnection[$connID]--;
- if ($reportStats or ($verb eq "yes") || ($usage =~ /y/)) {
- # if we didn't see the start time of this connection
- # i.e. due to truncation or log rotation
- # then just set to 0
- my $stoc = $hashes->{start_time_of_connection}->{$connID} || 0;
- $hashes->{end_time_of_connection}->{$connID} = $gmtime || 0;
- my $diff = $hashes->{end_time_of_connection}->{$connID} - $stoc;
- $hashes->{start_time_of_connection}->{$connID} =
$hashes->{end_time_of_connection}->{$connID} = 0;
- if ($diff <= 1) { $latency[0]++;}
- if ($diff == 2) { $latency[1]++;}
- if ($diff == 3) { $latency[2]++;}
- if ($diff >= 4 && $diff <=5 ) { $latency[3]++;}
- if ($diff >= 6 && $diff <=10 ) { $latency[4]++;}
- if ($diff >= 11 && $diff <=15 ) { $latency[5]++;}
- if ($diff >= 16) { $latency[6] ++;}
- }
+ handleConnClose($connID);
}
if (m/ BIND/ && $_ =~ /dn=\"(.*)\" method/i ){
my $binddn = $1;
@@ -1761,13 +1800,13 @@ sub parseLineNormal
$tmpp =~ tr/A-Z/a-z/;
$hashes->{bindlist}->{$tmpp}++;
if($usage =~ /f/ || $verb eq "yes"){
- $hashes->{bind_conn_op}->{"$conn,$op"} = $tmpp;
+ $hashes->{bind_conn_op}->{"$serverRestartCount,$conn,$op"} = $tmpp;
}
} else {
$anonymousBindCount++;
$hashes->{bindlist}->{"Anonymous Binds"}++;
if($usage =~ /f/ || $verb eq "yes"){
- $hashes->{bind_conn_op}->{"$conn,$op"} = "";
+ $hashes->{bind_conn_op}->{"$serverRestartCount,$conn,$op"} =
"";
}
inc_stats('anonbind',$s_stats,$m_stats);
}
@@ -1775,7 +1814,7 @@ sub parseLineNormal
if (m/ UNBIND/){
$unbindCount++;
if ($verb eq "yes"){
- if ($_ =~ /conn= *([0-9A-Z]+) +op= *([0-9\-]+)/i){
$hashes->{unbind_conn_op}->{"$1,$2"}++;}
+ if ($_ =~ /conn= *([0-9A-Z]+) +op= *([0-9\-]+)/i){
$hashes->{unbind_conn_op}->{"$serverRestartCount,$1,$2"}++;}
}
}
if (m/ RESULT err=/ && m/ notes=[A-Z,]*P/){
@@ -1795,11 +1834,11 @@ sub parseLineNormal
# unindexed search stat, as VLV unindexed searches aren't that bad
$unindexedSrchCountNotesA++;
if($reportStats){ inc_stats('notesA',$s_stats,$m_stats); }
- if ($usage =~ /u/ || $verb eq "yes"){
- $hashes->{notesa_conn_op}->{"$con,$op"}++;
- if ($_ =~ /etime= *([0-9.]+)/i ){
$hashes->{etime_conn_op}->{"$con,$op"} = $1; }
- if ($_ =~ / *([0-9a-z:\/]+)/i){ $hashes->{time_conn_op}->{"$con,$op"}
= $1; }
- if ($_ =~ /nentries= *([0-9]+)/i ){
$hashes->{nentries_conn_op}->{"$con,$op"} = $1; }
+ if ($usage =~ /u/ || $usage =~ /U/ || $verb eq "yes"){
+ $hashes->{notesa_conn_op}->{"$serverRestartCount,$con,$op"}++;
+ if ($_ =~ /etime= *([0-9.]+)/i ){
$hashes->{etime_conn_op}->{"$serverRestartCount,$con,$op"} = $1; }
+ if ($_ =~ / *([0-9a-z:\/]+)/i){
$hashes->{time_conn_op}->{"$serverRestartCount,$con,$op"} = $1; }
+ if ($_ =~ /nentries= *([0-9]+)/i ){
$hashes->{nentries_conn_op}->{"$serverRestartCount,$con,$op"} = $1; }
}
}
$isVlvNotes = 0;
@@ -1818,11 +1857,11 @@ sub parseLineNormal
# unindexed search stat, as VLV unindexed searches aren't that bad
$unindexedSrchCountNotesU++;
if($reportStats){ inc_stats('notesU',$s_stats,$m_stats); }
- if ($usage =~ /u/ || $verb eq "yes"){
- $hashes->{notesu_conn_op}->{"$con,$op"}++;
- if ($_ =~ /etime= *([0-9.]+)/i ){
$hashes->{etime_conn_op}->{"$con,$op"} = $1; }
- if ($_ =~ / *([0-9a-z:\/]+)/i){ $hashes->{time_conn_op}->{"$con,$op"}
= $1; }
- if ($_ =~ /nentries= *([0-9]+)/i ){
$hashes->{nentries_conn_op}->{"$con,$op"} = $1; }
+ if ($usage =~ /u/ || $usage =~ /U/ || $verb eq "yes"){
+ $hashes->{notesu_conn_op}->{"$serverRestartCount,$con,$op"}++;
+ if ($_ =~ /etime= *([0-9.]+)/i ){
$hashes->{etime_conn_op}->{"$serverRestartCount,$con,$op"} = $1; }
+ if ($_ =~ / *([0-9a-z:\/]+)/i){
$hashes->{time_conn_op}->{"$serverRestartCount,$con,$op"} = $1; }
+ if ($_ =~ /nentries= *([0-9]+)/i ){
$hashes->{nentries_conn_op}->{"$serverRestartCount,$con,$op"} = $1; }
}
}
$isVlvNotes = 0;
@@ -1885,14 +1924,14 @@ sub parseLineNormal
$hashes->{ip_hash}->{$ip}++;
if ($_ =~ /conn= *([0-9A-Z]+)/i ){
if ($exc ne "yes"){
- $hashes->{conn_hash}->{$1} = $ip;
+ $hashes->{conn_hash}->{"$serverRestartCount,$1"} = $ip;
}
}
}
if (m/- A1/){
if ($_ =~ /conn= *([0-9A-Z]+)/i) {
$exc = "no";
- $ip = getIPfromConn($1);
+ $ip = getIPfromConn($1, $serverRestartCount);
for (my $xxx = 0; $xxx < $#excludeIP; $xxx++){
if ($ip eq $excludeIP[$xxx]){$exc = "yes";}
}
@@ -1906,7 +1945,7 @@ sub parseLineNormal
if (m/- B1/){
if ($_ =~ /conn= *([0-9A-Z]+)/i) {
$exc = "no";
- $ip = getIPfromConn($1);
+ $ip = getIPfromConn($1, $serverRestartCount);
for (my $xxx = 0; $xxx < $#excludeIP; $xxx++){
if ($ip eq $excludeIP[$xxx]){$exc = "yes";}
}
@@ -1920,7 +1959,7 @@ sub parseLineNormal
if (m/- B4/){
if ($_ =~ /conn= *([0-9A-Z]+)/i) {
$exc = "no";
- $ip = getIPfromConn($1);
+ $ip = getIPfromConn($1, $serverRestartCount);
for (my $xxx = 0; $xxx < $#excludeIP; $xxx++){
if ($ip eq $excludeIP[$xxx]){$exc = "yes";}
}
@@ -1934,7 +1973,7 @@ sub parseLineNormal
if (m/- T1/){
if ($_ =~ /conn= *([0-9A-Z]+)/i) {
$exc = "no";
- $ip = getIPfromConn($1);
+ $ip = getIPfromConn($1, $serverRestartCount);
for (my $xxx = 0; $xxx < $#excludeIP; $xxx++){
if ($ip eq $excludeIP[$xxx]){$exc = "yes";}
}
@@ -1948,7 +1987,7 @@ sub parseLineNormal
if (m/- T2/){
if ($_ =~ /conn= *([0-9A-Z]+)/i) {
$exc = "no";
- $ip = getIPfromConn($1);
+ $ip = getIPfromConn($1, $serverRestartCount);
for (my $xxx = 0; $xxx < $#excludeIP; $xxx++){
if ($ip eq $excludeIP[$xxx]){$exc = "yes";}
}
@@ -1962,7 +2001,7 @@ sub parseLineNormal
if (m/- B2/){
if ($_ =~ /conn= *([0-9A-Z]+)/i) {
$exc = "no";
- $ip = getIPfromConn($1);
+ $ip = getIPfromConn($1, $serverRestartCount);
$maxBerSizeCount++;
for (my $xxx = 0; $xxx < $#excludeIP; $xxx++){
if ($ip eq $excludeIP[$xxx]){$exc = "yes";}
@@ -1977,7 +2016,7 @@ sub parseLineNormal
if (m/- B3/){
if ($_ =~ /conn= *([0-9A-Z]+)/i) {
$exc = "no";
- $ip = getIPfromConn($1);
+ $ip = getIPfromConn($1, $serverRestartCount);
for (my $xxx = 0; $xxx < $#excludeIP; $xxx++){
if ($ip eq $excludeIP[$xxx]){$exc = "yes";}
}
@@ -1991,7 +2030,7 @@ sub parseLineNormal
if (m/- R1/){
if ($_ =~ /conn= *([0-9A-Z]+)/i) {
$exc = "no";
- $ip = getIPfromConn($1);
+ $ip = getIPfromConn($1, $serverRestartCount);
for (my $xxx = 0; $xxx < $#excludeIP; $xxx++){
if ($ip eq $excludeIP[$xxx]){$exc = "yes";}
}
@@ -2005,7 +2044,7 @@ sub parseLineNormal
if (m/- P1/){
if ($_ =~ /conn= *([0-9A-Z]+)/i) {
$exc = "no";
- $ip = getIPfromConn($1);
+ $ip = getIPfromConn($1, $serverRestartCount);
for (my $xxx = 0; $xxx < $#excludeIP; $xxx++){
if ($ip eq $excludeIP[$xxx]){$exc = "yes";}
}
@@ -2019,7 +2058,7 @@ sub parseLineNormal
if (m/- P2/){
if ($_ =~ /conn= *([0-9A-Z]+)/i) {
$exc = "no";
- $ip = getIPfromConn($1);
+ $ip = getIPfromConn($1, $serverRestartCount);
for (my $xxx = 0; $xxx < $#excludeIP; $xxx++){
if ($ip eq $excludeIP[$xxx]){$exc = "yes";}
}
@@ -2033,7 +2072,7 @@ sub parseLineNormal
if (m/- U1/){
if ($_ =~ /conn= *([0-9A-Z]+)/i) {
$exc = "no";
- $ip = getIPfromConn($1);
+ $ip = getIPfromConn($1, $serverRestartCount);
for (my $xxx = 0; $xxx < $#excludeIP; $xxx++){
if ($ip eq $excludeIP[$xxx]){$exc = "yes";}
}
@@ -2062,10 +2101,10 @@ sub parseLineNormal
if ($_ =~ /oid=\" *([0-9\.]+)/i ){ $hashes->{oid}->{$1}++; }
if ($1 && $1 eq $startTLSoid){$startTLSCount++;}
if ($verb eq "yes"){
- if ($_ =~ /conn= *([0-9A-Z]+) +op= *([0-9\-]+)/i){
$hashes->{ext_conn_op}->{"$1,$2"}++;}
+ if ($_ =~ /conn= *([0-9A-Z]+) +op= *([0-9\-]+)/i){
$hashes->{ext_conn_op}->{"$serverRestartCount,$1,$2"}++;}
}
}
- if (($usage =~ /l/ || $verb eq "yes") and / SRCH /){
+ if (($usage =~ /l/ || $verb eq "yes" || $usage =~ /u/ || $usage =~ /U/) and /
SRCH /){
my ($filterConn, $filterOp);
if (/ SRCH / && / attrs=/ && $_ =~ /filter=\"(.*)\" /i ){
$tmpp = $1;
@@ -2083,13 +2122,13 @@ sub parseLineNormal
if ($_ =~ /op= *([0-9\-]+)/i) { $filterOp = $1; }
}
$filterCount++;
- if($usage =~ /u/ || $verb eq "yes"){
+ if($usage =~ /u/ || $usage =~ /U/ || $verb eq "yes"){
# we only need this for the unindexed search report
- $hashes->{filter_conn_op}->{"$filterConn,$filterOp"} = $tmpp;
+ $hashes->{filter_conn_op}->{"$serverRestartCount,$filterConn,$filterOp"}
= $tmpp;
}
}
- if ($usage =~ /a/ || $verb eq "yes"){
- if (/ SRCH / && $_ =~ /base=\"(.*)\" scope/i ){
+ if (($usage =~ /a/ || $verb eq "yes" || $usage =~ /u/ || $usage =~ /U/) and /
SRCH /){
+ if ($_ =~ /base=\"(.*)\" scope/i ){
my ($conn, $op, $scopeVal);
if ($1 eq ""){
$tmpp = "Root DSE";
@@ -2110,10 +2149,10 @@ sub parseLineNormal
if ($_ =~ /op= *([0-9\-]+)/i) {
$op = $1;
}
- if($usage =~ /u/ || $verb eq "yes"){
+ if($usage =~ /u/ || $usage =~ /U/ || $verb eq "yes"){
# we only need this for the unindexed search report
- $hashes->{base_conn_op}->{"$conn,$op"} = $tmpp;
- $hashes->{scope_conn_op}->{"$conn,$op"} = $scopeTxt[$scopeVal];
+ $hashes->{base_conn_op}->{"$serverRestartCount,$conn,$op"} = $tmpp;
+ $hashes->{scope_conn_op}->{"$serverRestartCount,$conn,$op"} =
$scopeTxt[$scopeVal];
}
$baseCount++;
$scopeCount++;
@@ -2133,7 +2172,9 @@ sub parseLineNormal
$badPwdCount++;
} elsif (/ err=49 tag=/ ){
$badPwdCount++;
- if ($_ =~ /conn= *([0-9A-Z]+) +op= *([0-9\-]+)/i){
$hashes->{badpwd_conn_op}->{"$1,$2"}++;}
+ if ($_ =~ /conn= *([0-9A-Z]+) +op= *([0-9\-]+)/i){
+ $hashes->{badpwd_conn_op}->{"$serverRestartCount,$1,$2"} =
getIPfromConn($1, $serverRestartCount);
+ }
}
}
if (/ BIND / && /method=sasl/i){
@@ -2394,9 +2435,11 @@ sub
getIPfromConn
{
my $connid = shift;
- if (exists($hashes->{conn_hash}->{$connid}) &&
- defined($hashes->{conn_hash}->{$connid})) {
- return $hashes->{conn_hash}->{$connid};
+ my $serverRestartCount = shift;
+ my $key = "$serverRestartCount,$connid";
+ if (exists($hashes->{conn_hash}->{$key}) &&
+ defined($hashes->{conn_hash}->{$key})) {
+ return $hashes->{conn_hash}->{$key};
}
return "Unknown_Host";
diff --git a/man/man1/logconv.pl.1 b/man/man1/logconv.pl.1
index c2a8cd8..46e7c96 100644
--- a/man/man1/logconv.pl.1
+++ b/man/man1/logconv.pl.1
@@ -21,7 +21,7 @@ logconv.pl \- analyzes Directory Server access log files
.B logconv.pl
[\fI\-h\fR] [\fI\-d <rootDN>\fR] [\fI\-s <size limit>\fR] [\fI\-v\fR]
[\fI\-V\fR]
[\fI\-S <start time>\fR] [\fI\-E <end time>\fR]
-[\fI\-efcibaltnxgju\fR] [\fI access log ... ... \fR]
+[\fI\-efcibaltnxgjuU\fR] [\fI access log ... ... \fR]
.PP
.SH DESCRIPTION
Analyzes Directory Server access log files for specific information defined on the
command
@@ -68,10 +68,10 @@ This option creates a CSV report for spreadsheets.
.B \fB\-B, \-\-bind\fR <ALL | ANONYMOUS | "Bind DN">
This generates a report based on either ALL bind dn's, anonymous binds, or a specific
DN.
.TP
-\fB\-V, \-\-verbose\fR <enable verbose output \- includes all stats listed below>
+\fB\-V, \-\-verbose\fR <enable verbose output \- includes all stats listed below
except U>
Verbose output
.TP
-.B \fB\-[efcibaltnxgju]\fR
+.B \fB\-[efcibaltnxgjuU]\fR
.br
\fBe\fR Error Code stats
.br
@@ -99,11 +99,13 @@ Verbose output
.br
\fBj\fR Recommendations
.br
-\fBu\fR Unindexed Search Stats
+\fBu\fR Unindexed Search Stats (very detailed)
.br
\fBy\fR Connection Latency Stats
.br
\fBp\fR Open Connection ID Stats
+.br
+\fBU\fR Unindexed Search Summary
.PP
.SH USAGE
Examples:
commit d890e65b4ab15d0a836dbb248da8606867938630
Author: Rich Megginson <rmeggins(a)redhat.com>
Date: Tue Jul 23 17:05:32 2013 -0600
Ticket #47501 logconv.pl uses /var/tmp for BDB temp files
https://fedorahosted.org/389/ticket/47501
Reviewed by: mreynolds (Thanks!)
Branch: master
Fix Description: Tied arrays with DB_RECNO require a backing text file. By
default this goes in /var/tmp. This can be controlled with RECNOINFO bfname.
However, the use of arrays was killing performance. This patch replaces
all arrays with tied hashes. In addition, this patch fixes the notes=U
handling to also handle notes=U,P and notes=A,P
Platforms tested: RHEL6 x86_64
Flag Day: no
Doc impact: no
(cherry picked from commit 4d20922423c9e22c858e0be7dd317591631cf357)
diff --git a/ldap/admin/src/logconv.pl b/ldap/admin/src/logconv.pl
index 3a6fa01..ca07a3a 100755
--- a/ldap/admin/src/logconv.pl
+++ b/ldap/admin/src/logconv.pl
@@ -67,7 +67,7 @@ if ($#ARGV < 0){;
my $file_count = 0;
my $arg_count = 0;
-my $logversion = "7.0";
+my $logversion = "8.0";
my $sizeCount = "20";
my $startFlag = 0;
my $startTime = 0;
@@ -76,6 +76,8 @@ my $endTime = 0;
my $reportStats = "";
my $dataLocation = "/tmp";
my $startTLSoid = "1.3.6.1.4.1.1466.20037";
+my @statnames=qw(last last_str results srch add mod modrdn moddn cmp del abandon
+ conns sslconns bind anonbind unbind notesA notesU etime);
my $s_stats = new_stats_block( );
my $m_stats = new_stats_block( );
my $verb = "no";
@@ -95,8 +97,6 @@ my %connList;
my %bindReport;
my @vlvconn;
my @vlvop;
-my @start_time_of_connection;
-my @end_time_of_connection;
my @fds;
my $fdds = 0;
my $reportBinds = "no";
@@ -179,7 +179,7 @@ if ($sizeCount eq "all"){$sizeCount = "100000";}
#######################################
# #
-# Initialize Arrays and variables #
+# Initialize Hashes and variables #
# #
#######################################
@@ -255,21 +255,17 @@ map {$conn{$_} = $_} @conncodes;
# hash db-backed hashes
my @hashnames = qw(attr rc src rsrc excount conn_hash ip_hash conncount nentries
- filter base ds6xbadpwd saslmech bindlist etime oid);
+ filter base ds6xbadpwd saslmech bindlist etime oid
+ start_time_of_connection end_time_of_connection
+ notesa_conn_op notesu_conn_op etime_conn_op nentries_conn_op
+ optype_conn_op time_conn_op srch_conn_op del_conn_op mod_conn_op
+ mdn_conn_op cmp_conn_op bind_conn_op unbind_conn_op ext_conn_op
+ abandon_conn_op badpwd_conn_op);
# need per connection code ip address counts - so use a hash table
# for each connection code - key is ip, val is count
push @hashnames, @conncodes;
my $hashes = openHashFiles($dataLocation, @hashnames);
-# recno db-backed arrays/lists
-my @arraynames = qw(srchconn srchop delconn delop modconn modop addconn addop modrdnconn
modrdnop
- cmpconn cmpop targetconn targetop msgid bindconn bindop binddn
unbindconn unbindop
- extconn extop notesAetime notesAconn notesAop notesAtime
notesAnentries
- notesUetime notesUconn notesUop notesUtime notesUnentries badpwdconn
- badpwdop badpwdip baseval baseconn baseop scopeval scopeconn scopeop
- filterval filterconn filterop);
-my $arrays = openArrayFiles($dataLocation, @arraynames);
-
$needCleanup = 1;
my @err;
@@ -636,6 +632,12 @@ Binds:
@<<<<<<<<<<<<
@<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
.
write STDOUT;
+# format/write messes up emacs autoformatting - inserting this dummy function
+# fixes that
+sub dummy {
+ my $bar = shift;
+}
+
print "\n";
print "Proxied Auth Operations: $proxiedAuthCount\n";
print "Persistent Searches: $persistentSrchCount\n";
@@ -658,115 +660,75 @@ print "Unindexed Components:
$unindexedSrchCountNotesU\n";
if ($verb eq "yes" || $usage =~ /u/){
if ($unindexedSrchCountNotesA > 0){
my $conn_hash = $hashes->{conn_hash};
- my $notesConn = $arrays->{notesAconn};
- my $notesOp = $arrays->{notesAop};
- my $notesEtime = $arrays->{notesAetime};
- my $notesTime = $arrays->{notesAtime};
- my $notesNentries = $arrays->{notesAnentries};
- my $base_val = $arrays->{baseval};
- my $base_conn = $arrays->{baseconn};
- my $base_op = $arrays->{baseop};
- my $scope_val = $arrays->{scopeval};
- my $scope_conn = $arrays->{scopeconn};
- my $scope_op = $arrays->{scopeop};
- my $filter_val = $arrays->{filterval};
- my $filter_conn = $arrays->{filterconn};
- my $filter_op = $arrays->{filterop};
- my $notesCount = "1";
+ my $notesa_conn_op = $hashes->{notesa_conn_op};
+ my $time_conn_op = $hashes->{time_conn_op};
+ my $etime_conn_op = $hashes->{etime_conn_op};
+ my $nentries_conn_op = $hashes->{nentries_conn_op};
+ my $base_conn_op = $hashes->{base_conn_op};
+ my $scope_conn_op = $hashes->{scope_conn_op};
+ my $filter_conn_op = $hashes->{filter_conn_op};
+
+ my $notesCount = 1;
my $unindexedIp;
-
- for (my $n = 0; $n < scalar(@{$notesEtime}); $n++){
- if(!$notesConn->[$n] || $notesConn->[$n] eq "" ||
- !$conn_hash->{$notesConn->[$n]} || $conn_hash->{$notesConn->[$n]} eq
""){
- $unindexedIp = "?";
+ while (my ($conn_op, $count) = each %{$notesa_conn_op}) {
+ my ($conn, $op) = split(",", $conn_op);
+ if (exists($conn_hash->{$conn}) && defined($conn_hash->{$conn})) {
+ $unindexedIp = $conn_hash->{$conn};
} else {
- $unindexedIp = $conn_hash->{$notesConn->[$n]};
+ $unindexedIp = "?";
}
- print "\n Unindexed Search #".$notesCount."\n"; $notesCount++;
- print " - Date/Time: $notesTime->[$n]\n";
- print " - Connection Number: $notesConn->[$n]\n";
- print " - Operation Number: $notesOp->[$n]\n";
- print " - Etime: $notesEtime->[$n]\n";
- print " - Nentries: $notesNentries->[$n]\n";
+ print "\n Unindexed Components #".$notesCount."\n";
$notesCount++;
+ print " - Date/Time: $time_conn_op->{$conn_op}\n";
+ print " - Connection Number: $conn\n";
+ print " - Operation Number: $op\n";
+ print " - Etime: $etime_conn_op->{$conn_op}\n";
+ print " - Nentries: $nentries_conn_op->{$conn_op}\n";
print " - IP Address: $unindexedIp\n";
-
- for (my $nnn = 0; $nnn < $baseCount; $nnn++){
- if(!$base_conn->[$nnn] || !$base_op->[$nnn]){ next; }
- if ($notesConn->[$n] eq $base_conn->[$nnn] && $notesOp->[$n] eq
$base_op->[$nnn]){
- print " - Search Base: $base_val->[$nnn]\n";
- last;
- }
+ if (exists($base_conn_op->{$conn_op}) &&
defined($base_conn_op->{$conn_op})) {
+ print " - Search Base: $base_conn_op->{$conn_op}\n";
}
- for (my $nnn = 0; $nnn < $scopeCount; $nnn++){
- if(!$scope_conn->[$nnn] || !$scope_op->[$nnn]){ next; }
- if ($notesConn->[$n] eq $scope_conn->[$nnn] && $notesOp->[$n] eq
$scope_op->[$nnn]){
- print " - Search Scope: $scope_val->[$nnn]\n";
- last;
- }
+ if (exists($scope_conn_op->{$conn_op}) &&
defined($scope_conn_op->{$conn_op})) {
+ print " - Search Scope: $scope_conn_op->{$conn_op}\n";
}
- for (my $nnn = 0; $nnn < $filterCount; $nnn++){
- if(!$filter_conn->[$nnn] || !$filter_op->[$nnn]){ next; }
- if ($notesConn->[$n] eq $filter_conn->[$nnn] && $notesOp->[$n] eq
$filter_op->[$nnn]){
- print " - Search Filter: $filter_val->[$nnn]\n";
- last;
- }
+ if (exists($filter_conn_op->{$conn_op}) &&
defined($filter_conn_op->{$conn_op})) {
+ print " - Search Filter: $filter_conn_op->{$conn_op}\n";
}
}
}
if ($unindexedSrchCountNotesU > 0){
my $conn_hash = $hashes->{conn_hash};
- my $notesConn = $arrays->{notesUconn};
- my $notesOp = $arrays->{notesUop};
- my $notesEtime = $arrays->{notesUetime};
- my $notesTime = $arrays->{notesUtime};
- my $notesNentries = $arrays->{notesUnentries};
- my $base_val = $arrays->{baseval};
- my $base_conn = $arrays->{baseconn};
- my $base_op = $arrays->{baseop};
- my $scope_val = $arrays->{scopeval};
- my $scope_conn = $arrays->{scopeconn};
- my $scope_op = $arrays->{scopeop};
- my $filter_val = $arrays->{filterval};
- my $filter_conn = $arrays->{filterconn};
- my $filter_op = $arrays->{filterop};
-
- my $notesCount = "1";
+ my $notesu_conn_op = $hashes->{notesu_conn_op};
+ my $time_conn_op = $hashes->{time_conn_op};
+ my $etime_conn_op = $hashes->{etime_conn_op};
+ my $nentries_conn_op = $hashes->{nentries_conn_op};
+ my $base_conn_op = $hashes->{base_conn_op};
+ my $scope_conn_op = $hashes->{scope_conn_op};
+ my $filter_conn_op = $hashes->{filter_conn_op};
+
+ my $notesCount = 1;
my $unindexedIp;
- for (my $n = 0; $n < scalar(@{$notesEtime}); $n++){
- if(!$notesConn->[$n] || $notesConn->[$n] eq "" ||
- !$conn_hash->{$notesConn->[$n]} || $conn_hash->{$notesConn->[$n]} eq
""){
- $unindexedIp = "?";
+ while (my ($conn_op, $count) = each %{$notesu_conn_op}) {
+ my ($conn, $op) = split(",", $conn_op);
+ if (exists($conn_hash->{$conn}) && defined($conn_hash->{$conn})) {
+ $unindexedIp = $conn_hash->{$conn};
} else {
- $unindexedIp = $conn_hash->{$notesConn->[$n]};
+ $unindexedIp = "?";
}
print "\n Unindexed Components #".$notesCount."\n";
$notesCount++;
- print " - Date/Time: $notesTime->[$n]\n";
- print " - Connection Number: $notesConn->[$n]\n";
- print " - Operation Number: $notesOp->[$n]\n";
- print " - Etime: $notesEtime->[$n]\n";
- print " - Nentries: $notesNentries->[$n]\n";
+ print " - Date/Time: $time_conn_op->{$conn_op}\n";
+ print " - Connection Number: $conn\n";
+ print " - Operation Number: $op\n";
+ print " - Etime: $etime_conn_op->{$conn_op}\n";
+ print " - Nentries: $nentries_conn_op->{$conn_op}\n";
print " - IP Address: $unindexedIp\n";
-
- for (my $nnn = 0; $nnn < $baseCount; $nnn++){
- if(!$base_conn->[$nnn] || !$base_op->[$nnn]){ next; }
- if ($notesConn->[$n] eq $base_conn->[$nnn] && $notesOp->[$n] eq
$base_op->[$nnn]){
- print " - Search Base: $base_val->[$nnn]\n";
- last;
- }
+ if (exists($base_conn_op->{$conn_op}) &&
defined($base_conn_op->{$conn_op})) {
+ print " - Search Base: $base_conn_op->{$conn_op}\n";
}
- for (my $nnn = 0; $nnn < $scopeCount; $nnn++){
- if(!$scope_conn->[$nnn] || !$scope_op->[$nnn]){ next; }
- if ($notesConn->[$n] eq $scope_conn->[$nnn] && $notesOp->[$n] eq
$scope_op->[$nnn]){
- print " - Search Scope: $scope_val->[$nnn]\n";
- last;
- }
+ if (exists($scope_conn_op->{$conn_op}) &&
defined($scope_conn_op->{$conn_op})) {
+ print " - Search Scope: $scope_conn_op->{$conn_op}\n";
}
- for (my $nnn = 0; $nnn < $filterCount; $nnn++){
- if(!$filter_conn->[$nnn] || !$filter_op->[$nnn]){ next; }
- if ($notesConn->[$n] eq $filter_conn->[$nnn] && $notesOp->[$n] eq
$filter_op->[$nnn]){
- print " - Search Filter: $filter_val->[$nnn]\n";
- last;
- }
+ if (exists($filter_conn_op->{$conn_op}) &&
defined($filter_conn_op->{$conn_op})) {
+ print " - Search Filter: $filter_conn_op->{$conn_op}\n";
}
}
}
@@ -800,7 +762,7 @@ if ($connResetByPeerCount > 0){
push @retext, sprintf " - %-4s (%2s)
%-40s\n",$src->{$key},$conn{$key},$connmsg{$key};
}
}
- print @retext;
+ print @retext;
print "\n";
}
@@ -813,8 +775,8 @@ if ($resourceUnavailCount > 0){
if ($conn{$key} eq ""){$conn{$key} = "**Resource Issue**";}
push @rtext, sprintf " - %-4s (%2s)
%-40s\n",$rsrc->{$key},$conn{$key},$connmsg{$key};
}
- }
- print @rtext;
+ }
+ print @rtext;
}
print "Max BER Size Exceeded: $maxBerSizeCount\n";
print "\n";
@@ -829,7 +791,7 @@ print " - SASL Binds: $saslBindCount\n";
if ($saslBindCount > 0){
my $saslmech = $hashes->{saslmech};
foreach my $saslb ( sort {$saslmech->{$b} <=> $saslmech->{$a} } (keys
%{$saslmech}) ){
- printf " %-4s %-12s\n",$saslmech->{$saslb}, $saslb;
+ printf " %-4s %-12s\n",$saslmech->{$saslb}, $saslb;
}
}
@@ -914,13 +876,13 @@ if ($usage =~ /e/i || $verb eq "yes"){
for (my $i = 0; $i <= $#errtext; $i++){
$errtext[$i] =~ s/\n//g;
print "\n" . $errtext[$i];
- }
+ }
}
####################################
-# #
+# #
# Print Failed Logins #
-# #
+# #
####################################
if ($verb eq "yes" || $usage =~ /f/ ){
@@ -936,19 +898,20 @@ if ($verb eq "yes" || $usage =~ /f/ ){
$ds6loop++;
}
} else {
- my $bindVal = $arrays->{binddn};
- my $bindConn = $arrays->{bindconn};
- my $bindOp = $arrays->{bindop};
- my $badPasswordConn = $arrays->{badpwdconn};
- my $badPasswordOp = $arrays->{badpwdop};
- my $badPasswordIp = $arrays->{badpwdip};
+ # key is conn,op - val is binddn
+ my $bind_conn_op = $hashes->{bind_conn_op};
+ # key is conn,op - val is count
+ my $badpwd_conn_op = $hashes->{badpwd_conn_op};
+ # key is binddn - val is count
my %badPassword = ();
- for (my $ii =0 ; $ii < $badPwdCount; $ii++){
- for (my $i = 0; $i < $bindCount; $i++){
- if ($badPasswordConn->[$ii] eq $bindConn->[$i] &&
$badPasswordOp->[$ii] eq $bindOp->[$i] ){
- $badPassword{ $bindVal->[$i] }++;
- }
- }
+ my @badPasswordIp = ();
+ while (my ($conn_op, $count) = each %{$badpwd_conn_op}) {
+ my ($conn, $op) = split(",", $conn_op);
+ if (exists($bind_conn_op->{$conn_op}) &&
defined($bind_conn_op->{$conn_op})) {
+ my $binddn = $bind_conn_op->{$conn_op};
+ $badPassword{$binddn}++;
+ push @badPasswordIp, getIPfromConn($conn);
+ }
}
# sort the new hash of $badPassword{}
my $bpTotal = 0;
@@ -961,7 +924,7 @@ if ($verb eq "yes" || $usage =~ /f/ ){
}
print "\nFrom the IP address(s) :\n\n";
for (my $i=0; $i<$badPwdCount; $i++) {
- print "\t\t$badPasswordIp->[$i]\n";
+ print "\t\t$badPasswordIp[$i]\n";
}
if ($bpTotal > $badPwdCount){
print "\n** Warning : Wrongly reported failed login attempts : ". ($bpTotal
- $badPwdCount) . "\n";
@@ -982,11 +945,11 @@ if ($connCodeCount > 0){
print "\n\n----- Total Connection Codes -----\n\n";
my $conncount = $hashes->{conncount};
my @conntext;
- foreach my $key (sort { $conncount->{$b} <=> $conncount->{$a} } keys
%{$conncount}) {
- if ($conncount->{$key} > 0){
+ foreach my $key (sort { $conncount->{$b} <=> $conncount->{$a} } keys
%{$conncount}) {
+ if ($conncount->{$key} > 0){
push @conntext, sprintf "%-4s %6s
%-40s\n",$key,$conncount->{$key},$connmsg{ $key };
- }
- }
+ }
+ }
print @conntext;
}
}
@@ -1005,8 +968,8 @@ if ($usage =~ /i/i || $verb eq "yes"){
my $ip_count = ($#ipkeys + 1)-($#exxCount + 1);
my $ccount = 0;
if ($ip_count > 0){
- print "\n\n----- Top $sizeCount Clients -----\n\n";
- print "Number of Clients: $ip_count\n\n";
+ print "\n\n----- Top $sizeCount Clients -----\n\n";
+ print "Number of Clients: $ip_count\n\n";
foreach my $key (sort { $ip_hash->{$b} <=> $ip_hash->{$a} } @ipkeys) {
my $exc = "no";
if ($ccount > $sizeCount){ last;}
@@ -1021,7 +984,7 @@ if ($usage =~ /i/i || $verb eq "yes"){
my %counts;
map { $counts{$_} = $hashes->{$_}->{$key} if
(defined($hashes->{$_}->{$key})) } @conncodes;
foreach my $code (sort { $counts{$b} <=> $counts{$a} } keys %counts) {
- if ($code eq 'count' ) { next; }
+ if ($code eq 'count' ) { next; }
printf "%10s - %s (%s)\n", $counts{ $code }, $code, $connmsg{ $code };
}
print "\n";
@@ -1042,14 +1005,14 @@ if ($usage =~ /b/i || $verb eq "yes"){
my $bind_count = $#bindkeys + 1;
if ($bind_count > 0){
print "\n\n----- Top $sizeCount Bind DN's -----\n\n";
- print "Number of Unique Bind DN's: $bind_count\n\n";
+ print "Number of Unique Bind DN's: $bind_count\n\n";
my $bindcount = 0;
foreach my $dn (sort { $bindlist->{$b} <=> $bindlist->{$a} } @bindkeys) {
- if ($bindcount < $sizeCount){
+ if ($bindcount < $sizeCount){
printf "%-8s %-40s\n", $bindlist->{ $dn },$dn;
} else {
- last;
- }
+ last;
+ }
$bindcount++;
}
}
@@ -1070,16 +1033,16 @@ if ($usage =~ /a/i || $verb eq "yes"){
print "Number of Unique Search Bases: $base_count\n\n";
my $basecount = 0;
foreach my $bas (sort { $base->{$b} <=> $base->{$a} } @basekeys) {
- if ($basecount < $sizeCount){
- printf "%-8s %-40s\n", $base->{ $bas },$bas;
- } else {
- last;
- }
- $basecount++;
+ if ($basecount < $sizeCount){
+ printf "%-8s %-40s\n", $base->{ $bas },$bas;
+ } else {
+ last;
+ }
+ $basecount++;
}
}
}
-
+
#########################################
# #
# Gather and process search filters #
@@ -1091,15 +1054,15 @@ if ($usage =~ /l/ || $verb eq "yes"){
my @filterkeys = keys %{$filter};
my $filter_count = $#filterkeys + 1;
if ($filter_count > 0){
- print "\n\n----- Top $sizeCount Search Filters -----\n";
+ print "\n\n----- Top $sizeCount Search Filters -----\n";
print "\nNumber of Unique Search Filters: $filter_count\n\n";
my $filtercount = 0;
foreach my $filt (sort { $filter->{$b} <=> $filter->{$a} } @filterkeys){
if ($filtercount < $sizeCount){
printf "%-8s %-40s\n", $filter->{$filt}, $filt;
} else {
- last;
- }
+ last;
+ }
$filtercount++;
}
}
@@ -1108,7 +1071,7 @@ if ($usage =~ /l/ || $verb eq "yes"){
#########################################
# #
# Gather and Process the unique etimes #
-# #
+# #
#########################################
my $first;
@@ -1139,7 +1102,7 @@ if ($usage =~ /t/i || $verb eq "yes"){
if ($eloop == $sizeCount) { last; }
printf "%-12s %-10s\n","etime=$et",$etime->{ $et };
$eloop++;
- }
+ }
}
#######################################
@@ -1156,7 +1119,7 @@ if ($usage =~ /n/i || $verb eq "yes"){
my $eloop = 0;
foreach my $nentry (sort { $b <=> $a } @nkeys){
if ($eloop == $sizeCount) { last; }
- printf "%-18s %12s\n","nentries=$nentry", $nentries->{
$nentry };
+ printf "%-18s %12s\n","nentries=$nentry", $nentries->{ $nentry
};
$eloop++;
}
print "\n\n----- Top $sizeCount Most returned nentries -----\n\n";
@@ -1216,7 +1179,7 @@ if ($usage =~ /x/i || $verb eq "yes"){
}
############################################
-# #
+# #
# Print most commonly requested attributes #
# #
############################################
@@ -1235,7 +1198,7 @@ if ($usage =~ /r/i || $verb eq "yes"){
}
#############################
-# #
+# #
# abandoned operation stats #
# #
#############################
@@ -1244,66 +1207,49 @@ if ($usage =~ /g/i || $verb eq "yes"){
my $abandonTotal = $srchCount + $delCount + $modCount + $addCount + $modrdnCount +
$bindCount + $extopCount + $cmpCount;
if ($verb eq "yes" && $abandonCount > 0 && $abandonTotal
> 0){
my $conn_hash = $hashes->{conn_hash};
+ my $abandon_conn_op = $hashes->{abandon_conn_op};
+ my $srch_conn_op = $hashes->{srch_conn_op};
+ my $del_conn_op = $hashes->{del_conn_op};
+ my $add_conn_op = $hashes->{add_conn_op};
+ my $mod_conn_op = $hashes->{mod_conn_op};
+ my $cmp_conn_op = $hashes->{cmp_conn_op};
+ my $mdn_conn_op = $hashes->{mdn_conn_op};
+ my $bind_conn_op = $hashes->{bind_conn_op};
+ my $unbind_conn_op = $hashes->{unbind_conn_op};
+ my $ext_conn_op = $hashes->{ext_conn_op};
print "\n\n----- Abandon Request Stats -----\n\n";
- for (my $g = 0; $g < $abandonCount; $g++){
- my $conn = $arrays->{targetconn}->[$g];
- my $op = $arrays->{targetop}->[$g];
- my $msgid = $arrays->{msgid}->[$g];
- for (my $sc = 0; $sc < $srchCount; $sc++){
- if (($arrays->{srchconn}->[$sc] && $arrays->{srchop}->[$sc])
&&
- ($arrays->{srchconn}->[$sc] eq $conn &&
$arrays->{srchop}->[$sc] eq $op )){
- print " - SRCH conn=$conn op=$op msgid=$msgid
client=$conn_hash->{$conn}\n";
- }
- }
- for (my $dc = 0; $dc < $delCount; $dc++){
- if (($arrays->{delconn}->[$dc] && $arrays->{delop}->[$dc])
&&
- ($arrays->{delconn}->[$dc] eq $conn &&
$arrays->{delop}->[$dc] eq $op)){
- print " - DEL conn=$conn op=$op msgid=$msgid
client=$conn_hash->{$conn}\n";
- }
- }
- for (my $adc = 0; $adc < $addCount; $adc++){
- if (($arrays->{addconn}->[$adc] && $arrays->{addop}->[$adc])
&&
- ($arrays->{addconn}->[$adc] eq $conn &&
$arrays->{addop}->[$adc] eq $op)){
- print " - ADD conn=$conn op=$op msgid=$msgid
client=$conn_hash->{$conn}\n";
- }
- }
- for (my $mc = 0; $mc < $modCount; $mc++){
- if (($arrays->{modconn}->[$mc] && $arrays->{modop}->[$mc])
&&
- ($arrays->{modconn}->[$mc] eq $conn &&
$arrays->{modop}->[$mc] eq $op)){
- print " - MOD conn=$conn op=$op msgid=$msgid
client=$conn_hash->{$conn}\n";
- }
- }
- for (my $cc = 0; $cc < $cmpCount; $cc++){
- if (($arrays->{cmpconn}->[$cc] && $arrays->{cmpop}->[$cc])
&&
- ($arrays->{cmpconn}->[$cc] eq $conn &&
$arrays->{cmpop}->[$cc] eq $op)){
- print " - CMP conn=$conn op=$op msgid=$msgid
client=$conn_hash->{$conn}\n";
- }
- }
- for (my $mdc = 0; $mdc < $modrdnCount; $mdc++){
- if (($arrays->{modrdnconn}->[$mdc] &&
$arrays->{modrdnop}->[$mdc]) &&
- ($arrays->{modrdnconn}->[$mdc] eq $conn &&
$arrays->{modrdnop}->[$mdc] eq $op)){
- print " - MODRDN conn=$conn op=$op msgid=$msgid
client=$conn_hash->{$conn}\n";
- }
- }
- for (my $bcb = 0; $bcb < $bindCount; $bcb++){
- if (($arrays->{bindconn}->[$bcb] && $arrays->{bindop}->[$bcb])
&&
- ($arrays->{bindconn}->[$bcb] eq $conn &&
$arrays->{bindop}->[$bcb] eq $op)){
- print " - BIND conn=$conn op=$op msgid=$msgid
client=$conn_hash->{$conn}\n";
- }
- }
- for (my $ubc = 0; $ubc < $unbindCount; $ubc++){
- if (($arrays->{unbindconn}->[$ubc] &&
$arrays->{unbindop}->[$ubc]) &&
- ($arrays->{unbindconn}->[$ubc] eq $conn &&
$arrays->{unbindop}->[$ubc] eq $op)){
- print " - UNBIND conn=$conn op=$op msgid=$msgid
client=$conn_hash->{$conn}\n";
- }
+ while (my ($conn_op, $targ_msgid) = each %{$abandon_conn_op}) {
+ my ($conn, $op) = split(",", $conn_op);
+ my ($targetop, $msgid) = split(",", $targ_msgid);
+ my $conn_targ = "$conn,$targetop";
+ my $clientIP;
+ if (exists($conn_hash->{$conn}) && defined($conn_hash->{$conn})) {
+ $clientIP = $conn_hash->{$conn};
+ } else {
+ $clientIP = "Unknown";
}
- for (my $ec = 0; $ec < $extopCount; $ec++){
- if (($arrays->{extconn}->[$ec] && $arrays->{extop}->[$ec])
&&
- ($arrays->{extconn}->[$ec] eq $conn &&
$arrays->{extop}->[$ec] eq $op)){
- print " - EXT conn=$conn op=$op msgid=$msgid
client=$conn_hash->{$conn}\n";
- }
+ if (exists($srch_conn_op->{$conn_targ}) &&
defined($srch_conn_op->{$conn_targ})) {
+ print " - SRCH conn=$conn op=$targetop msgid=$msgid client=$clientIP\n";
+ } elsif (exists($del_conn_op->{$conn_targ}) &&
defined($del_conn_op->{$conn_targ})) {
+ print " - DEL conn=$conn op=$targetop msgid=$msgid client=$clientIP\n";
+ } elsif (exists($add_conn_op->{$conn_targ}) &&
defined($add_conn_op->{$conn_targ})) {
+ print " - ADD conn=$conn op=$targetop msgid=$msgid client=$clientIP\n";
+ } elsif (exists($mod_conn_op->{$conn_targ}) &&
defined($mod_conn_op->{$conn_targ})) {
+ print " - MOD conn=$conn op=$targetop msgid=$msgid client=$clientIP\n";
+ } elsif (exists($cmp_conn_op->{$conn_targ}) &&
defined($cmp_conn_op->{$conn_targ})) {
+ print " - CMP conn=$conn op=$targetop msgid=$msgid client=$clientIP\n";
+ } elsif (exists($mdn_conn_op->{$conn_targ}) &&
defined($mdn_conn_op->{$conn_targ})) {
+ print " - MODRDN conn=$conn op=$targetop msgid=$msgid client=$clientIP\n";
+ } elsif (exists($bind_conn_op->{$conn_targ}) &&
defined($bind_conn_op->{$conn_targ})) {
+ print " - BIND conn=$conn op=$targetop msgid=$msgid client=$clientIP\n";
+ } elsif (exists($unbind_conn_op->{$conn_targ}) &&
defined($unbind_conn_op->{$conn_targ})) {
+ print " - UNBIND conn=$conn op=$targetop msgid=$msgid client=$clientIP\n";
+ } elsif (exists($ext_conn_op->{$conn_targ}) &&
defined($ext_conn_op->{$conn_targ})) {
+ print " - EXT conn=$conn op=$targetop msgid=$msgid client=$clientIP\n";
+ } else {
+ print " - UNKNOWN conn=$conn op=$targetop msgid=$msgid
client=$clientIP\n";
}
}
}
@@ -1390,8 +1336,8 @@ sub displayUsage {
print "Usage:\n\n";
print " ./logconv.pl [-h] [-d|--rootdn <rootDN>] [-s|--sizeLimit <size
limit>] [-v|verison] [-Vi|verbose]\n";
- print " [-S|--startTime <start time>] [-E|--endTime <end time>]
\n";
- print " [-efcibaltnxrgjuyp] [ access log ... ... ]\n\n";
+ print " [-S|--startTime <start time>] [-E|--endTime <end time>]
\n";
+ print " [-efcibaltnxrgjuyp] [ access log ... ... ]\n\n";
print "- Commandline Switches:\n\n";
@@ -1400,7 +1346,7 @@ sub displayUsage {
print " -D, --data <Location for temporary data files>
default is \"/tmp\"\n";
print " -s, --sizeLimit <Number of results to return per catagory>
default is 20\n";
print " -X, --excludeIP <IP address to exclude from connection
stats> E.g. Load balancers\n";
- print " -v, --version show version of tool\n";
+ print " -v, --version show version of tool\n";
print " -S, --startTime <time to begin analyzing logfile
from>\n";
print " E.g. \"[28/Mar/2002:13:14:22 -0800]\"\n";
print " -E, --endTime <time to stop analyzing logfile>\n";
@@ -1450,7 +1396,7 @@ sub displayUsage {
sub
parseLine {
if($reportBinds eq "yes"){
- &parseLineBind();
+ &parseLineBind();
} else {
&parseLineNormal();
}
@@ -1469,26 +1415,26 @@ parseLineBind {
return if $_ =~ /^\s/;
if($firstFile == 1 && $_ =~ /^\[/){
- $start = $_;
- if ($start =~ / *([0-9a-z:\/]+)/i){$start=$1;}
- $firstFile = 0;
+ $start = $_;
+ if ($start =~ / *([0-9a-z:\/]+)/i){$start=$1;}
+ $firstFile = 0;
}
if ($endFlag != 1 && $_ =~ /^\[/ && $_ =~ / *([0-9a-z:\/]+)/i){
$end =$1;
}
if ($startTime && !$startFlag) {
- if (index($_, $startTime) == 0) {
- $startFlag = 1;
- ($start) = $startTime =~ /\D*(\S*)/;
- } else {
- return;
- }
+ if (index($_, $startTime) == 0) {
+ $startFlag = 1;
+ ($start) = $startTime =~ /\D*(\S*)/;
+ } else {
+ return;
+ }
}
if ($endTime && !$endFlag) {
- if (index($_, $endTime) == 0) {
- $endFlag = 1;
- ($end) = $endTime =~ /\D*(\S*)/;
- }
+ if (index($_, $endTime) == 0) {
+ $endFlag = 1;
+ ($end) = $endTime =~ /\D*(\S*)/;
+ }
}
if ($_ =~ /connection from *([0-9A-Fa-f\.\:]+)/i ) {
my $skip = "yes";
@@ -1497,8 +1443,8 @@ parseLineBind {
$skip = "yes";
last;
}
- }
- if ($skip eq "yes"){
+ }
+ if ($skip eq "yes"){
return ;
}
$ip = $1;
@@ -1507,9 +1453,9 @@ parseLineBind {
}
return;
}
- if (/ BIND/ && $_ =~ /dn=\"(.*)\" method/i ){
+ if (/ BIND/ && $_ =~ /dn=\"(.*)\" method/i ){
my $dn;
- if ($1 eq ""){
+ if ($1 eq ""){
$dn = "Anonymous";
} else {
$dn = $1;
@@ -1522,7 +1468,7 @@ parseLineBind {
}
}
$bindReport{$dn}{"binds"}++;
- if ($bindReport{$dn}{"binds"} == 1){
+ if ($bindReport{$dn}{"binds"} == 1){
# For hashes we need to init the counters
$bindReport{$dn}{"srch"} = 0;
$bindReport{$dn}{"add"} = 0;
@@ -1537,7 +1483,7 @@ parseLineBind {
$bindReport{$dn}{"conn"} = $bindReport{$dn}{"conn"} . " $1
";
}
return;
- }
+ }
if (/ RESULT err=49 /){
processOpForBindReport("failedBind",$logline);
}
@@ -1547,7 +1493,7 @@ parseLineBind {
processOpForBindReport("add",$logline);
} elsif (/ MOD dn=/){
processOpForBindReport("mod",$logline);
- } elsif (/ DEL dn=/){
+ } elsif (/ DEL dn=/){
processOpForBindReport("del",$logline);
} elsif (/ MODRDN dn=/){
processOpForBindReport("modrdn",$logline);
@@ -1555,7 +1501,7 @@ parseLineBind {
processOpForBindReport("cmp",$logline);
} elsif (/ EXT oid=/){
processOpForBindReport("ext",$logline);
- }
+ }
}
sub
@@ -1625,13 +1571,13 @@ sub parseLineNormal
if(!defined($lastzone) or $tzone ne $lastzone)
{
- # tz offset change
- $lastzone=$tzone;
- my ($sign,$hr,$min) = $tzone =~ m/(.)(\d\d)(\d\d)/;
- $tzoff = $hr*3600 + $min*60;
- $tzoff *= -1
- if $sign eq '-';
- # to be subtracted from converted values.
+ # tz offset change
+ $lastzone=$tzone;
+ my ($sign,$hr,$min) = $tzone =~ m/(.)(\d\d)(\d\d)/;
+ $tzoff = $hr*3600 + $min*60;
+ $tzoff *= -1
+ if $sign eq '-';
+ # to be subtracted from converted values.
}
my ($date, $hr, $min, $sec) = split (':', $time);
my ($day, $mon, $yr) = split ('/', $date);
@@ -1641,15 +1587,15 @@ sub parseLineNormal
reset_stats_block( $s_stats, $gmtime, $time.' '.$tzone );
if (!defined($last_min) or $newmin != $last_min)
{
- print_stats_block( $m_stats );
- $time =~ s/\d\d$/00/;
- reset_stats_block( $m_stats, $newmin, $time.' '.$tzone );
- $last_min = $newmin;
+ print_stats_block( $m_stats );
+ $time =~ s/\d\d$/00/;
+ reset_stats_block( $m_stats, $newmin, $time.' '.$tzone );
+ $last_min = $newmin;
}
}
- if (m/ RESULT err/){
- $allResults++;
+ if (m/ RESULT err/){
+ $allResults++;
if($reportStats){ inc_stats('results',$s_stats,$m_stats); }
}
if (m/ SRCH/){
@@ -1666,58 +1612,57 @@ sub parseLineNormal
$anyAttrs++;
}
if ($verb eq "yes"){
- if ($_ =~ /conn= *([0-9A-Z]+)/i){ push @{$arrays->{srchconn}}, $1;}
- if ($_ =~ /op= *([0-9\-]+)/i){ push @{$arrays->{srchop}}, $1;}
+ if ($_ =~ /conn= *([0-9A-Z]+) +op= *([0-9\-]+)/i){
$hashes->{srch_conn_op}->{"$1,$2"}++;}
}
}
if (m/ DEL/){
$delCount++;
if($reportStats){ inc_stats('del',$s_stats,$m_stats); }
if ($verb eq "yes"){
- if ($_ =~ /conn= *([0-9A-Z]+)/i){ push @{$arrays->{delconn}}, $1;}
- if ($_ =~ /op= *([0-9\-]+)/i){ push @{$arrays->{delop}}, $1;}
+ if ($_ =~ /conn= *([0-9A-Z]+) +op= *([0-9\-]+)/i){
$hashes->{del_conn_op}->{"$1,$2"}++;}
}
}
if (m/ MOD dn=/){
$modCount++;
if($reportStats){ inc_stats('mod',$s_stats,$m_stats); }
if ($verb eq "yes"){
- if ($_ =~ /conn= *([0-9A-Z]+)/i){ push @{$arrays->{modconn}}, $1;}
- if ($_ =~ /op= *([0-9\-]+)/i){ push @{$arrays->{modop}}, $1; }
+ if ($_ =~ /conn= *([0-9A-Z]+) +op= *([0-9\-]+)/i){
$hashes->{mod_conn_op}->{"$1,$2"}++;}
}
}
if (m/ ADD/){
$addCount++;
if($reportStats){ inc_stats('add',$s_stats,$m_stats); }
if ($verb eq "yes"){
- if ($_ =~ /conn= *([0-9A-Z]+)/i){ push @{$arrays->{addconn}}, $1; }
- if ($_ =~ /op= *([0-9\-]+)/i){ push @{$arrays->{addop}}, $1; }
+ if ($_ =~ /conn= *([0-9A-Z]+) +op= *([0-9\-]+)/i){
$hashes->{add_conn_op}->{"$1,$2"}++;}
}
}
if (m/ MODRDN/){
$modrdnCount++;
if($reportStats){ inc_stats('modrdn',$s_stats,$m_stats); }
if ($verb eq "yes"){
- if ($_ =~ /conn= *([0-9A-Z]+)/i){ push @{$arrays->{modrdnconn}}, $1; }
- if ($_ =~ /op= *([0-9\-]+)/i){ push @{$arrays->{modrdnop}}, $1; }
+ if ($_ =~ /conn= *([0-9A-Z]+) +op= *([0-9\-]+)/i){
$hashes->{mdn_conn_op}->{"$1,$2"}++;}
}
}
if (m/ CMP dn=/){
$cmpCount++;
if($reportStats){ inc_stats('cmp',$s_stats,$m_stats); }
if ($verb eq "yes" || $usage =~ /g/i){
- if ($_ =~ /conn= *([0-9A-Z]+)/i){ push @{$arrays->{cmpconn}}, $1;}
- if ($_ =~ /op= *([0-9\-]+)/i){ push @{$arrays->{cmpop}}, $1;}
+ if ($_ =~ /conn= *([0-9A-Z]+) +op= *([0-9\-]+)/i){
$hashes->{cmp_conn_op}->{"$1,$2"}++;}
}
}
if (m/ ABANDON /){
+ # there are two cases for abandon
+ # [17/Sep/2013:01:52:11 -0400] conn=1482074 op=4 ABANDON targetop=3 msgid=4
+ # [17/Sep/2013:01:52:11 -0400] conn=1482074 op=4 ABANDON targetop=NOTFOUND msgid=4
+ # if the op to be abandoned completes before the abandon request can be processed
+ # the server will use NOTFOUND as the op number
$abandonCount++;
if($reportStats){ inc_stats('abandon',$s_stats,$m_stats); }
$allResults++;
- if ($_ =~ /targetop= *([0-9a-zA-Z]+)/i ){
- push @{$arrays->{targetop}}, $1;
- if ($_ =~ /conn= *([0-9A-Z]+)/i){ push @{$arrays->{targetconn}}, $1; }
- if ($_ =~ /msgid= *([0-9\-]+)/i){ push @{$arrays->{msgid}}, $1; }
+ if ($_ =~ /conn= *([0-9A-Z]+) +op= *([0-9\-]+) +ABANDON +targetop= *([0-9a-zA-Z]+)
+msgid= *([0-9\-]+)/i ){
+ # abandon_conn_op - key is the conn,op of the ABANDON request
+ # the value is the targetop,msgid of the ABANDON request
+ $hashes->{abandon_conn_op}->{"$1,$2"} = "$3,$4"; #
targetop,msgid
}
}
if (m/ VLV /){
@@ -1738,11 +1683,11 @@ sub parseLineNormal
$autobindCount++;
$bindCount++;
if($reportStats){ inc_stats('bind',$s_stats,$m_stats); }
- if ($1 ne ""){
+ if ($1 ne ""){
$tmpp = $1;
$tmpp =~ tr/A-Z/a-z/;
$hashes->{bindlist}->{$tmpp}++;
- if($1 eq $rootDN){
+ if($1 eq $rootDN){
$rootDNBindCount++;
}
} else {
@@ -1752,7 +1697,7 @@ sub parseLineNormal
}
}
if (m/ connection from/){
- if ($_ =~ /connection from *([0-9A-Fa-f\.\:]+)/i ){
+ if ($_ =~ /connection from *([0-9A-Fa-f\.\:]+)/i ){
for (my $xxx =0; $xxx < $#excludeIP; $xxx++){
if ($excludeIP[$xxx] eq $1){$exc = "yes";}
}
@@ -1763,7 +1708,7 @@ sub parseLineNormal
}
$simConnection++;
if ($simConnection > $maxsimConnection) {
- $maxsimConnection = $simConnection;
+ $maxsimConnection = $simConnection;
}
($connID) = $_ =~ /conn=(\d*)\s/;
$openConnection[$connID]++;
@@ -1772,7 +1717,7 @@ sub parseLineNormal
my ($date, $hr, $min, $sec) = split (':', $time);
my ($day, $mon, $yr) = split ('/', $date);
$day =~ s/\[//;
- $start_time_of_connection[$connID] = timegm($sec, $min, $hr, $day, $monthname{$mon},
$yr);
+ $hashes->{start_time_of_connection}->{$connID} = timegm($sec, $min, $hr, $day,
$monthname{$mon}, $yr);
}
}
if (m/ SSL client bound as /){$sslClientBindCount++;}
@@ -1788,10 +1733,10 @@ sub parseLineNormal
# if we didn't see the start time of this connection
# i.e. due to truncation or log rotation
# then just set to 0
- my $stoc = $start_time_of_connection[$connID] || 0;
- $end_time_of_connection[$connID] = $gmtime || 0;
- my $diff = $end_time_of_connection[$connID] - $stoc;
- $start_time_of_connection[$connID] = $end_time_of_connection[$connID] = 0;
+ my $stoc = $hashes->{start_time_of_connection}->{$connID} || 0;
+ $hashes->{end_time_of_connection}->{$connID} = $gmtime || 0;
+ my $diff = $hashes->{end_time_of_connection}->{$connID} - $stoc;
+ $hashes->{start_time_of_connection}->{$connID} =
$hashes->{end_time_of_connection}->{$connID} = 0;
if ($diff <= 1) { $latency[0]++;}
if ($diff == 2) { $latency[1]++;}
if ($diff == 3) { $latency[2]++;}
@@ -1802,85 +1747,82 @@ sub parseLineNormal
}
}
if (m/ BIND/ && $_ =~ /dn=\"(.*)\" method/i ){
+ my $binddn = $1;
if($reportStats){ inc_stats('bind',$s_stats,$m_stats); }
$bindCount++;
- if ($1 ne ""){
- if($1 eq $rootDN){$rootDNBindCount++;}
- $tmpp = $1;
+ my ($conn, $op);
+ if ($_ =~ /conn= *([0-9A-Z]+) +op= *([0-9\-]+)/i){
+ $conn = $1;
+ $op = $2;
+ }
+ if ($binddn ne ""){
+ if($binddn eq $rootDN){$rootDNBindCount++;}
+ $tmpp = $binddn;
$tmpp =~ tr/A-Z/a-z/;
$hashes->{bindlist}->{$tmpp}++;
- if ($_ =~ /conn= *([0-9A-Z]+)/i) { push @{$arrays->{bindconn}}, $1;}
- if ($_ =~ /op= *([0-9\-]+)/i) { push @{$arrays->{bindop}}, $1;}
if($usage =~ /f/ || $verb eq "yes"){
- push @{$arrays->{binddn}}, $tmpp;
+ $hashes->{bind_conn_op}->{"$conn,$op"} = $tmpp;
}
} else {
$anonymousBindCount++;
$hashes->{bindlist}->{"Anonymous Binds"}++;
- if ($_ =~ /conn= *([0-9A-Z]+)/i) { push @{$arrays->{bindconn}}, $1;}
- if ($_ =~ /op= *([0-9\-]+)/i) { push @{$arrays->{bindop}}, $1;}
- push @{$arrays->{binddn}}, "";
+ if($usage =~ /f/ || $verb eq "yes"){
+ $hashes->{bind_conn_op}->{"$conn,$op"} = "";
+ }
inc_stats('anonbind',$s_stats,$m_stats);
}
}
if (m/ UNBIND/){
$unbindCount++;
if ($verb eq "yes"){
- if ($_ =~ /conn= *([0-9A-Z]+)/i){ push @{$arrays->{unbindconn}}, $1; }
- if ($_ =~ /op= *([0-9\-]+)/i){ push @{$arrays->{unbindop}}, $1; }
+ if ($_ =~ /conn= *([0-9A-Z]+) +op= *([0-9\-]+)/i){
$hashes->{unbind_conn_op}->{"$1,$2"}++;}
}
}
- if (m/ RESULT err=/ && m/ notes=P/){
+ if (m/ RESULT err=/ && m/ notes=[A-Z,]*P/){
$pagedSearchCount++;
}
- if (m/ notes=A/){
+ if (m/ notes=[A-Z,]*A/){
$con = "";
if ($_ =~ /conn= *([0-9A-Z]+)/i){
- $con = $1;
- if ($_ =~ /op= *([0-9\-]+)/i){ $op = $1;}
+ $con = $1;
+ if ($_ =~ /op= *([0-9\-]+)/i){ $op = $1;}
}
for (my $i=0; $i < $vlvCount;$i++){
- if ($vlvconn[$i] eq $con && $vlvop[$i] eq $op){ $vlvNotesACount++;
$isVlvNotes="1";}
+ if ($vlvconn[$i] eq $con && $vlvop[$i] eq $op){ $vlvNotesACount++;
$isVlvNotes="1";}
}
if($isVlvNotes == 0){
# We don't want to record vlv unindexed searches for our regular "bad"
# unindexed search stat, as VLV unindexed searches aren't that bad
$unindexedSrchCountNotesA++;
if($reportStats){ inc_stats('notesA',$s_stats,$m_stats); }
- }
- if ($usage =~ /u/ || $verb eq "yes"){
- if ($isVlvNotes == 0 ){
- if ($_ =~ /etime= *([0-9.]+)/i ){ push @{$arrays->{notesAetime}}, $1; }
- if ($_ =~ /conn= *([0-9A-Z]+)/i){ push @{$arrays->{notesAconn}}, $1; }
- if ($_ =~ /op= *([0-9\-]+)/i){ push @{$arrays->{notesAop}}, $1; }
- if ($_ =~ / *([0-9a-z:\/]+)/i){ push @{$arrays->{notesAtime}}, $1; }
- if ($_ =~ /nentries= *([0-9]+)/i ){ push @{$arrays->{notesAnentries}}, $1; }
+ if ($usage =~ /u/ || $verb eq "yes"){
+ $hashes->{notesa_conn_op}->{"$con,$op"}++;
+ if ($_ =~ /etime= *([0-9.]+)/i ){
$hashes->{etime_conn_op}->{"$con,$op"} = $1; }
+ if ($_ =~ / *([0-9a-z:\/]+)/i){ $hashes->{time_conn_op}->{"$con,$op"}
= $1; }
+ if ($_ =~ /nentries= *([0-9]+)/i ){
$hashes->{nentries_conn_op}->{"$con,$op"} = $1; }
}
}
$isVlvNotes = 0;
}
- if (m/ notes=U/){
+ if (m/ notes=[A-Z,]*U/){
$con = "";
if ($_ =~ /conn= *([0-9A-Z]+)/i){
- $con = $1;
- if ($_ =~ /op= *([0-9\-]+)/i){ $op = $1;}
+ $con = $1;
+ if ($_ =~ /op= *([0-9\-]+)/i){ $op = $1;}
}
for (my $i=0; $i < $vlvCount;$i++){
- if ($vlvconn[$i] eq $con && $vlvop[$i] eq $op){ $vlvNotesUCount++;
$isVlvNotes="1";}
+ if ($vlvconn[$i] eq $con && $vlvop[$i] eq $op){ $vlvNotesUCount++;
$isVlvNotes="1";}
}
if($isVlvNotes == 0){
# We don't want to record vlv unindexed searches for our regular "bad"
# unindexed search stat, as VLV unindexed searches aren't that bad
$unindexedSrchCountNotesU++;
if($reportStats){ inc_stats('notesU',$s_stats,$m_stats); }
- }
- if ($usage =~ /u/ || $verb eq "yes"){
- if ($isVlvNotes == 0 ){
- if ($_ =~ /etime= *([0-9.]+)/i ){ push @{$arrays->{notesUetime}}, $1; }
- if ($_ =~ /conn= *([0-9A-Z]+)/i){ push @{$arrays->{notesUconn}}, $1; }
- if ($_ =~ /op= *([0-9\-]+)/i){ push @{$arrays->{notesUop}}, $1; }
- if ($_ =~ / *([0-9a-z:\/]+)/i){ push @{$arrays->{notesUtime}}, $1; }
- if ($_ =~ /nentries= *([0-9]+)/i ){ push @{$arrays->{notesUnentries}}, $1; }
+ if ($usage =~ /u/ || $verb eq "yes"){
+ $hashes->{notesu_conn_op}->{"$con,$op"}++;
+ if ($_ =~ /etime= *([0-9.]+)/i ){
$hashes->{etime_conn_op}->{"$con,$op"} = $1; }
+ if ($_ =~ / *([0-9a-z:\/]+)/i){ $hashes->{time_conn_op}->{"$con,$op"}
= $1; }
+ if ($_ =~ /nentries= *([0-9]+)/i ){
$hashes->{nentries_conn_op}->{"$con,$op"} = $1; }
}
}
$isVlvNotes = 0;
@@ -1941,8 +1883,8 @@ sub parseLineNormal
}
$ip = $1;
$hashes->{ip_hash}->{$ip}++;
- if ($_ =~ /conn= *([0-9A-Z]+)/i ){
- if ($exc ne "yes"){
+ if ($_ =~ /conn= *([0-9A-Z]+)/i ){
+ if ($exc ne "yes"){
$hashes->{conn_hash}->{$1} = $ip;
}
}
@@ -1951,7 +1893,6 @@ sub parseLineNormal
if ($_ =~ /conn= *([0-9A-Z]+)/i) {
$exc = "no";
$ip = getIPfromConn($1);
- if ($ip eq ""){$ip = "Unknown_Host";}
for (my $xxx = 0; $xxx < $#excludeIP; $xxx++){
if ($ip eq $excludeIP[$xxx]){$exc = "yes";}
}
@@ -1966,14 +1907,13 @@ sub parseLineNormal
if ($_ =~ /conn= *([0-9A-Z]+)/i) {
$exc = "no";
$ip = getIPfromConn($1);
- if ($ip eq ""){$ip = "Unknown_Host";}
for (my $xxx = 0; $xxx < $#excludeIP; $xxx++){
- if ($ip eq $excludeIP[$xxx]){$exc = "yes";}
+ if ($ip eq $excludeIP[$xxx]){$exc = "yes";}
}
if ($exc ne "yes"){
$hashes->{B1}->{$ip}++;
$hashes->{conncount}->{"B1"}++;
- $connCodeCount++;
+ $connCodeCount++;
}
}
}
@@ -1981,44 +1921,41 @@ sub parseLineNormal
if ($_ =~ /conn= *([0-9A-Z]+)/i) {
$exc = "no";
$ip = getIPfromConn($1);
- if ($ip eq ""){$ip = "Unknown_Host";}
for (my $xxx = 0; $xxx < $#excludeIP; $xxx++){
- if ($ip eq $excludeIP[$xxx]){$exc = "yes";}
+ if ($ip eq $excludeIP[$xxx]){$exc = "yes";}
}
if ($exc ne "yes"){
$hashes->{B4}->{$ip}++;
$hashes->{conncount}->{"B4"}++;
$connCodeCount++;
}
- }
+ }
}
if (m/- T1/){
if ($_ =~ /conn= *([0-9A-Z]+)/i) {
$exc = "no";
- $ip = getIPfromConn($1);
- if ($ip eq ""){$ip = "Unknown_Host";}
+ $ip = getIPfromConn($1);
for (my $xxx = 0; $xxx < $#excludeIP; $xxx++){
- if ($ip eq $excludeIP[$xxx]){$exc = "yes";}
+ if ($ip eq $excludeIP[$xxx]){$exc = "yes";}
}
if ($exc ne "yes"){
$hashes->{T1}->{$ip}++;
$hashes->{conncount}->{"T1"}++;
- $connCodeCount++;
+ $connCodeCount++;
}
}
}
if (m/- T2/){
if ($_ =~ /conn= *([0-9A-Z]+)/i) {
- $exc = "no";
+ $exc = "no";
$ip = getIPfromConn($1);
- if ($ip eq ""){$ip = "Unknown_Host";}
for (my $xxx = 0; $xxx < $#excludeIP; $xxx++){
- if ($ip eq $excludeIP[$xxx]){$exc = "yes";}
+ if ($ip eq $excludeIP[$xxx]){$exc = "yes";}
}
if ($exc ne "yes"){
$hashes->{T2}->{$ip}++;
$hashes->{conncount}->{"T2"}++;
- $connCodeCount++;
+ $connCodeCount++;
}
}
}
@@ -2027,14 +1964,13 @@ sub parseLineNormal
$exc = "no";
$ip = getIPfromConn($1);
$maxBerSizeCount++;
- if ($ip eq ""){$ip = "Unknown_Host";}
for (my $xxx = 0; $xxx < $#excludeIP; $xxx++){
- if ($ip eq $excludeIP[$xxx]){$exc = "yes";}
+ if ($ip eq $excludeIP[$xxx]){$exc = "yes";}
}
if ($exc ne "yes"){
$hashes->{B2}->{$ip}++;
$hashes->{conncount}->{"B2"}++;
- $connCodeCount++;
+ $connCodeCount++;
}
}
}
@@ -2042,14 +1978,13 @@ sub parseLineNormal
if ($_ =~ /conn= *([0-9A-Z]+)/i) {
$exc = "no";
$ip = getIPfromConn($1);
- if ($ip eq ""){$ip = "Unknown_Host";}
for (my $xxx = 0; $xxx < $#excludeIP; $xxx++){
- if ($ip eq $excludeIP[$xxx]){$exc = "yes";}
+ if ($ip eq $excludeIP[$xxx]){$exc = "yes";}
}
if ($exc ne "yes"){
$hashes->{B3}->{$ip}++;
$hashes->{conncount}->{"B3"}++;
- $connCodeCount++;
+ $connCodeCount++;
}
}
}
@@ -2057,9 +1992,8 @@ sub parseLineNormal
if ($_ =~ /conn= *([0-9A-Z]+)/i) {
$exc = "no";
$ip = getIPfromConn($1);
- if ($ip eq ""){$ip = "Unknown_Host";}
for (my $xxx = 0; $xxx < $#excludeIP; $xxx++){
- if ($ip eq $excludeIP[$xxx]){$exc = "yes";}
+ if ($ip eq $excludeIP[$xxx]){$exc = "yes";}
}
if ($exc ne "yes"){
$hashes->{R1}->{$ip}++;
@@ -2072,14 +2006,13 @@ sub parseLineNormal
if ($_ =~ /conn= *([0-9A-Z]+)/i) {
$exc = "no";
$ip = getIPfromConn($1);
- if ($ip eq ""){$ip = "Unknown_Host";}
for (my $xxx = 0; $xxx < $#excludeIP; $xxx++){
- if ($ip eq $excludeIP[$xxx]){$exc = "yes";}
+ if ($ip eq $excludeIP[$xxx]){$exc = "yes";}
}
if ($exc ne "yes"){
$hashes->{P1}->{$ip}++;
$hashes->{conncount}->{"P1"}++;
- $connCodeCount++;
+ $connCodeCount++;
}
}
}
@@ -2087,9 +2020,8 @@ sub parseLineNormal
if ($_ =~ /conn= *([0-9A-Z]+)/i) {
$exc = "no";
$ip = getIPfromConn($1);
- if ($ip eq ""){$ip = "Unknown_Host";}
for (my $xxx = 0; $xxx < $#excludeIP; $xxx++){
- if ($ip eq $excludeIP[$xxx]){$exc = "yes";}
+ if ($ip eq $excludeIP[$xxx]){$exc = "yes";}
}
if ($exc ne "yes"){
$hashes->{P2}->{$ip}++;
@@ -2102,9 +2034,8 @@ sub parseLineNormal
if ($_ =~ /conn= *([0-9A-Z]+)/i) {
$exc = "no";
$ip = getIPfromConn($1);
- if ($ip eq ""){$ip = "Unknown_Host";}
for (my $xxx = 0; $xxx < $#excludeIP; $xxx++){
- if ($ip eq $excludeIP[$xxx]){$exc = "yes";}
+ if ($ip eq $excludeIP[$xxx]){$exc = "yes";}
}
if ($exc ne "yes"){
$hashes->{U1}->{$ip}++;
@@ -2131,8 +2062,7 @@ sub parseLineNormal
if ($_ =~ /oid=\" *([0-9\.]+)/i ){ $hashes->{oid}->{$1}++; }
if ($1 && $1 eq $startTLSoid){$startTLSCount++;}
if ($verb eq "yes"){
- if ($_ =~ /conn= *([0-9A-Z]+)/i){ push @{$arrays->{extconn}}, $1; }
- if ($_ =~ /op= *([0-9\-]+)/i){ push @{$arrays->{extop}}, $1; }
+ if ($_ =~ /conn= *([0-9A-Z]+) +op= *([0-9\-]+)/i){
$hashes->{ext_conn_op}->{"$1,$2"}++;}
}
}
if (($usage =~ /l/ || $verb eq "yes") and / SRCH /){
@@ -2155,14 +2085,12 @@ sub parseLineNormal
$filterCount++;
if($usage =~ /u/ || $verb eq "yes"){
# we only need this for the unindexed search report
- push @{$arrays->{filterval}}, $tmpp;
- push @{$arrays->{filterconn}}, $filterConn;
- push @{$arrays->{filterop}}, $filterOp;
+ $hashes->{filter_conn_op}->{"$filterConn,$filterOp"} = $tmpp;
}
}
if ($usage =~ /a/ || $verb eq "yes"){
if (/ SRCH / && $_ =~ /base=\"(.*)\" scope/i ){
- my ($baseConn, $baseOp, $scopeVal, $scopeConn, $scopeOp);
+ my ($conn, $op, $scopeVal);
if ($1 eq ""){
$tmpp = "Root DSE";
} else {
@@ -2173,25 +2101,19 @@ sub parseLineNormal
#
# grab the search bases & scope for potential unindexed searches
#
- if ($_ =~ /scope= *([0-9]+)/i) {
- $scopeVal = $1;
+ if ($_ =~ /scope= *([0-9]+)/i) {
+ $scopeVal = $1;
}
- if ($_ =~ /conn= *([0-9A-Z]+)/i) {
- $baseConn = $1;
- $scopeConn = $1;
+ if ($_ =~ /conn= *([0-9A-Z]+)/i) {
+ $conn = $1;
}
- if ($_ =~ /op= *([0-9\-]+)/i) {
- $baseOp = $1;
- $scopeOp = $1;
+ if ($_ =~ /op= *([0-9\-]+)/i) {
+ $op = $1;
}
if($usage =~ /u/ || $verb eq "yes"){
# we only need this for the unindexed search report
- push @{$arrays->{baseval}}, $tmpp;
- push @{$arrays->{baseconn}}, $baseConn;
- push @{$arrays->{baseop}}, $baseOp;
- push @{$arrays->{scopeval}}, $scopeTxt[$scopeVal];
- push @{$arrays->{scopeconn}}, $scopeConn;
- push @{$arrays->{scopeop}}, $scopeOp;
+ $hashes->{base_conn_op}->{"$conn,$op"} = $tmpp;
+ $hashes->{scope_conn_op}->{"$conn,$op"} = $scopeTxt[$scopeVal];
}
$baseCount++;
$scopeCount++;
@@ -2210,15 +2132,8 @@ sub parseLineNormal
$ds6x = "true";
$badPwdCount++;
} elsif (/ err=49 tag=/ ){
- if ($_ =~ /conn= *([0-9A-Z]+)/i ){
- push @{$arrays->{badpwdconn}}, $1;
- $ip = getIPfromConn($1);
- $badPwdCount++;
- }
- if ($_ =~ /op= *([0-9\-]+)/i ){
- push @{$arrays->{badpwdop}}, $1;
- }
- push @{$arrays->{badpwdip}}, $ip;
+ $badPwdCount++;
+ if ($_ =~ /conn= *([0-9A-Z]+) +op= *([0-9\-]+)/i){
$hashes->{badpwd_conn_op}->{"$1,$2"}++;}
}
}
if (/ BIND / && /method=sasl/i){
@@ -2259,29 +2174,17 @@ sub parseLineNormal
sub
reset_stats_block
{
- my $stats = shift;
-
- $stats->{'last'} = shift || 0;
- $stats->{'last_str'} = shift || '';
-
- $stats->{'results'}=0;
- $stats->{'srch'}=0;
- $stats->{'add'}=0;
- $stats->{'mod'}=0;
- $stats->{'modrdn'}=0;
- $stats->{'moddn'}=0;
- $stats->{'cmp'}=0;
- $stats->{'del'}=0;
- $stats->{'abandon'}=0;
- $stats->{'conns'}=0;
- $stats->{'sslconns'}=0;
- $stats->{'bind'}=0;
- $stats->{'anonbind'}=0;
- $stats->{'unbind'}=0;
- $stats->{'notesA'}=0;
- $stats->{'notesU'}=0;
- $stats->{'etime'}=0;
- return;
+ my $stats = shift;
+
+ $stats->{'last'} = shift || 0;
+ $stats->{'last_str'} = shift || '';
+
+ for my $sn (@statnames) {
+ next if ($sn eq 'last' or $sn eq 'last_str');
+ $stats->{$sn}=0;
+ }
+
+ return;
}
sub
@@ -2292,6 +2195,7 @@ new_stats_block
'active' => 0,
};
if ($name){
+ $stats = openHashFiles($dataLocation, @statnames);
$stats->{'filename'} = $name;
$stats->{'fh'} = new IO::File;
$stats->{'active'} = open($stats->{'fh'},">$name");
@@ -2308,32 +2212,32 @@ print_stats_block
if ($stats->{'active'}){
if ($stats->{'last'}){
$stats->{'fh'}->print(
- join(',',
- $stats->{'last_str'},
- $stats->{'last'},
- $stats->{'results'},
- $stats->{'srch'},
- $stats->{'add'},
- $stats->{'mod'},
- $stats->{'modrdn'},
- $stats->{'moddn'},
- $stats->{'cmp'},
- $stats->{'del'},
- $stats->{'abandon'},
- $stats->{'conns'},
- $stats->{'sslconns'},
- $stats->{'bind'},
- $stats->{'anonbind'},
- $stats->{'unbind'},
- $stats->{'notesA'},
- $stats->{'notesU'},
- $stats->{'etime'}),
- "\n" );
+ join(',',
+ $stats->{'last_str'},
+ $stats->{'last'},
+ $stats->{'results'},
+ $stats->{'srch'},
+ $stats->{'add'},
+ $stats->{'mod'},
+ $stats->{'modrdn'},
+ $stats->{'moddn'},
+ $stats->{'cmp'},
+ $stats->{'del'},
+ $stats->{'abandon'},
+ $stats->{'conns'},
+ $stats->{'sslconns'},
+ $stats->{'bind'},
+ $stats->{'anonbind'},
+ $stats->{'unbind'},
+ $stats->{'notesA'},
+ $stats->{'notesU'},
+ $stats->{'etime'}),
+ "\n" );
} else {
$stats->{'fh'}->print(
-
"Time,time_t,Results,Search,Add,Mod,Modrdn,Moddn,Compare,Delete,Abandon,".
- "Connections,SSL Conns,Bind,Anon Bind,Unbind,Unindexed search,Unindexed
component,ElapsedTime\n"
- );
+ "Time,time_t,Results,Search,Add,Mod,Modrdn,Moddn,Compare,Delete,Abandon,".
+ "Connections,SSL Conns,Bind,Anon Bind,Unbind,Unindexed search,Unindexed
component,ElapsedTime\n"
+ );
}
}
}
@@ -2346,7 +2250,7 @@ inc_stats
my $n = shift;
foreach(@_){
$_->{$n}++
- if exists $_->{$n};
+ if exists $_->{$n};
}
return;
}
@@ -2360,7 +2264,7 @@ inc_stats_val
my $val = shift;
foreach(@_){
$_->{$n} += $val
- if exists $_->{$n};
+ if exists $_->{$n};
}
return;
}
@@ -2383,7 +2287,7 @@ displayBindReport
&printClients($bindReport{$bindDN}{"conn"});
print("\n Operations Performed:\n\n");
&printOpStats($bindDN);
- print("\n");
+ print("\n");
}
print "Done.\n";
exit (0);
@@ -2391,13 +2295,13 @@ displayBindReport
sub
printClients
-{
+{
my @bindConns = &cleanConns(split(' ', $_[0]));
my $IPcount = "1";
foreach my $ip ( keys %connList ){ # Loop over all the IP addresses
foreach my $bc (@bindConns){ # Loop over each bind conn number and compare it
- if($connList{$ip} =~ / $bc /){
+ if($connList{$ip} =~ / $bc /){
print(" [$IPcount] $ip\n");
$IPcount++;
last;
@@ -2417,7 +2321,7 @@ cleanConns
if($dirtyConns[$i] ne ""){
$retConns[$c++] = $dirtyConns[$i];
}
- }
+ }
return @retConns;
}
@@ -2443,7 +2347,7 @@ printOpStats
#######################
# #
# Hash File Functions #
-# #
+# #
#######################
sub
@@ -2471,35 +2375,17 @@ openHashFiles
}
sub
-openArrayFiles
-{
- my $dir = shift;
- my %arrays = ();
- for my $an (@_) {
- my @ary = (); # using my in inner loop will create brand new array every time through
for tie
- my $fn = "$dir/$an.logconv.db";
- push @removefiles, $fn;
- tie @ary, "DB_File", $fn, O_CREAT|O_RDWR, 0600, $DB_RECNO or do {
openFailed($!, $fn) };
- $arrays{$an} = \@ary;
- }
- return \%arrays;
-}
-
-sub
removeDataFiles
{
- if (!$needCleanup) { return ; }
+ if (!$needCleanup) { return ; }
for my $h (keys %{$hashes}) {
untie %{$hashes->{$h}};
}
- for my $a (keys %{$arrays}) {
- untie @{$arrays->{$a}};
- }
for my $file (@removefiles) {
unlink $file;
}
- $needCleanup = 0;
+ $needCleanup = 0;
}
END { print "Cleaning up temp files . . .\n"; removeDataFiles(); print
"Done\n"; }
@@ -2508,7 +2394,12 @@ sub
getIPfromConn
{
my $connid = shift;
- return $hashes->{conn_hash}->{$connid};
+ if (exists($hashes->{conn_hash}->{$connid}) &&
+ defined($hashes->{conn_hash}->{$connid})) {
+ return $hashes->{conn_hash}->{$connid};
+ }
+
+ return "Unknown_Host";
}
#######################################
commit 2c5d52b7a4aef8317cc9e34a9b1153c74620010d
Author: Mark Reynolds <mreynolds(a)redhat.com>
Date: Mon Sep 23 11:32:16 2013 -0400
Ticket 47520 - Fix various issues with logconv.pl
Bug Description: When testing an access log that contains "internal"
connections/ops, many
warning messages are created. Other warnings are generated because
the
DB_File arrays need to have thier elements checked before comparing
to other
strings.
Fix Description: Improve value checking. Add support for connection numbers that are
words (Internal),
and negative values for op ids(-1).
https://fedorahosted.org/389/ticket/47520
Reviewed by: richm(Thanks!)
(cherry picked from commit 8b153e999ac6dc4869498a78da103a07db49d28e)
diff --git a/ldap/admin/src/logconv.pl b/ldap/admin/src/logconv.pl
index ec0fdf5..3a6fa01 100755
--- a/ldap/admin/src/logconv.pl
+++ b/ldap/admin/src/logconv.pl
@@ -102,6 +102,7 @@ my $fdds = 0;
my $reportBinds = "no";
my $rootDN = "";
my $needCleanup = 0;
+my @scopeTxt = ("0 (base)", "1 (one)", "2 (subtree)");
GetOptions(
'd|rootDN=s' => \$rootDN,
@@ -653,6 +654,7 @@ print "Entire Search Base Queries:
$objectclassTopCount\n";
print "Paged Searches: $pagedSearchCount\n";
print "Unindexed Searches: $unindexedSrchCountNotesA\n";
print "Unindexed Components: $unindexedSrchCountNotesU\n";
+
if ($verb eq "yes" || $usage =~ /u/){
if ($unindexedSrchCountNotesA > 0){
my $conn_hash = $hashes->{conn_hash};
@@ -670,11 +672,12 @@ if ($verb eq "yes" || $usage =~ /u/){
my $filter_val = $arrays->{filterval};
my $filter_conn = $arrays->{filterconn};
my $filter_op = $arrays->{filterop};
-
my $notesCount = "1";
my $unindexedIp;
+
for (my $n = 0; $n < scalar(@{$notesEtime}); $n++){
- if($conn_hash->{$notesConn->[$n]} eq ""){
+ if(!$notesConn->[$n] || $notesConn->[$n] eq "" ||
+ !$conn_hash->{$notesConn->[$n]} || $conn_hash->{$notesConn->[$n]} eq
""){
$unindexedIp = "?";
} else {
$unindexedIp = $conn_hash->{$notesConn->[$n]};
@@ -688,18 +691,21 @@ if ($verb eq "yes" || $usage =~ /u/){
print " - IP Address: $unindexedIp\n";
for (my $nnn = 0; $nnn < $baseCount; $nnn++){
+ if(!$base_conn->[$nnn] || !$base_op->[$nnn]){ next; }
if ($notesConn->[$n] eq $base_conn->[$nnn] && $notesOp->[$n] eq
$base_op->[$nnn]){
print " - Search Base: $base_val->[$nnn]\n";
last;
}
}
for (my $nnn = 0; $nnn < $scopeCount; $nnn++){
+ if(!$scope_conn->[$nnn] || !$scope_op->[$nnn]){ next; }
if ($notesConn->[$n] eq $scope_conn->[$nnn] && $notesOp->[$n] eq
$scope_op->[$nnn]){
print " - Search Scope: $scope_val->[$nnn]\n";
last;
}
}
for (my $nnn = 0; $nnn < $filterCount; $nnn++){
+ if(!$filter_conn->[$nnn] || !$filter_op->[$nnn]){ next; }
if ($notesConn->[$n] eq $filter_conn->[$nnn] && $notesOp->[$n] eq
$filter_op->[$nnn]){
print " - Search Filter: $filter_val->[$nnn]\n";
last;
@@ -727,7 +733,8 @@ if ($verb eq "yes" || $usage =~ /u/){
my $notesCount = "1";
my $unindexedIp;
for (my $n = 0; $n < scalar(@{$notesEtime}); $n++){
- if($conn_hash->{$notesConn->[$n]} eq ""){
+ if(!$notesConn->[$n] || $notesConn->[$n] eq "" ||
+ !$conn_hash->{$notesConn->[$n]} || $conn_hash->{$notesConn->[$n]} eq
""){
$unindexedIp = "?";
} else {
$unindexedIp = $conn_hash->{$notesConn->[$n]};
@@ -741,18 +748,21 @@ if ($verb eq "yes" || $usage =~ /u/){
print " - IP Address: $unindexedIp\n";
for (my $nnn = 0; $nnn < $baseCount; $nnn++){
+ if(!$base_conn->[$nnn] || !$base_op->[$nnn]){ next; }
if ($notesConn->[$n] eq $base_conn->[$nnn] && $notesOp->[$n] eq
$base_op->[$nnn]){
print " - Search Base: $base_val->[$nnn]\n";
last;
}
}
for (my $nnn = 0; $nnn < $scopeCount; $nnn++){
+ if(!$scope_conn->[$nnn] || !$scope_op->[$nnn]){ next; }
if ($notesConn->[$n] eq $scope_conn->[$nnn] && $notesOp->[$n] eq
$scope_op->[$nnn]){
print " - Search Scope: $scope_val->[$nnn]\n";
last;
}
}
for (my $nnn = 0; $nnn < $filterCount; $nnn++){
+ if(!$filter_conn->[$nnn] || !$filter_op->[$nnn]){ next; }
if ($notesConn->[$n] eq $filter_conn->[$nnn] && $notesOp->[$n] eq
$filter_op->[$nnn]){
print " - Search Filter: $filter_val->[$nnn]\n";
last;
@@ -772,13 +782,12 @@ if ($brokenPipeCount > 0){
my @etext;
foreach my $key (sort { $rc->{$b} <=> $rc->{$a} } keys %{$rc}) {
if ($rc->{$key} > 0){
- if ($conn{$key} eq ""){$conn{$key} = "**Unknown**";}
- push @etext, sprintf " - %-4s (%2s)
%-40s\n",$rc->{$key},$conn{$key},$connmsg{$key
-};
- }
- }
- print @etext;
- print "\n";
+ if ($conn{$key} eq ""){$conn{$key} = "**Unknown**";}
+ push @etext, sprintf " - %-4s (%2s)
%-40s\n",$rc->{$key},$conn{$key},$connmsg{$key};
+ }
+ }
+ print @etext;
+ print "\n";
}
print "Connections Reset By Peer: $connResetByPeerCount\n";
@@ -787,12 +796,11 @@ if ($connResetByPeerCount > 0){
my @retext;
foreach my $key (sort { $src->{$b} <=> $src->{$a} } keys %{$src}) {
if ($src->{$key} > 0){
- if ($conn{$key} eq ""){$conn{$key} = "**Unknown**";}
- push @retext, sprintf " - %-4s (%2s)
%-40s\n",$src->{$key},$conn{$key},$connmsg{$key
-};
- }
- }
- print @retext;
+ if ($conn{$key} eq ""){$conn{$key} = "**Unknown**";}
+ push @retext, sprintf " - %-4s (%2s)
%-40s\n",$src->{$key},$conn{$key},$connmsg{$key};
+ }
+ }
+ print @retext;
print "\n";
}
@@ -802,9 +810,9 @@ if ($resourceUnavailCount > 0){
my @rtext;
foreach my $key (sort { $rsrc->{$b} <=> $rsrc->{$a} } keys %{$rsrc}) {
if ($rsrc->{$key} > 0){
- if ($conn{$key} eq ""){$conn{$key} = "**Resource
Issue**";}
- push @rtext, sprintf " - %-4s (%2s)
%-40s\n",$rsrc->{$key},$conn{$key},$connmsg{$key};
- }
+ if ($conn{$key} eq ""){$conn{$key} = "**Resource Issue**";}
+ push @rtext, sprintf " - %-4s (%2s)
%-40s\n",$rsrc->{$key},$conn{$key},$connmsg{$key};
+ }
}
print @rtext;
}
@@ -1244,48 +1252,57 @@ if ($usage =~ /g/i || $verb eq "yes"){
my $op = $arrays->{targetop}->[$g];
my $msgid = $arrays->{msgid}->[$g];
for (my $sc = 0; $sc < $srchCount; $sc++){
- if ($arrays->{srchconn}->[$sc] eq $conn &&
$arrays->{srchop}->[$sc] eq $op ){
+ if (($arrays->{srchconn}->[$sc] && $arrays->{srchop}->[$sc])
&&
+ ($arrays->{srchconn}->[$sc] eq $conn &&
$arrays->{srchop}->[$sc] eq $op )){
print " - SRCH conn=$conn op=$op msgid=$msgid
client=$conn_hash->{$conn}\n";
}
}
for (my $dc = 0; $dc < $delCount; $dc++){
- if ($arrays->{delconn}->[$dc] eq $conn && $arrays->{delop}->[$dc]
eq $op){
- print " - DEL conn=$conn op=$op msgid=$msgid
client=$conn_hash->{$conn}\n";
+ if (($arrays->{delconn}->[$dc] && $arrays->{delop}->[$dc])
&&
+ ($arrays->{delconn}->[$dc] eq $conn &&
$arrays->{delop}->[$dc] eq $op)){
+ print " - DEL conn=$conn op=$op msgid=$msgid
client=$conn_hash->{$conn}\n";
}
}
for (my $adc = 0; $adc < $addCount; $adc++){
- if ($arrays->{addconn}->[$adc] eq $conn &&
$arrays->{addop}->[$adc] eq $op){
- print " - ADD conn=$conn op=$op msgid=$msgid
client=$conn_hash->{$conn}\n";
+ if (($arrays->{addconn}->[$adc] && $arrays->{addop}->[$adc])
&&
+ ($arrays->{addconn}->[$adc] eq $conn &&
$arrays->{addop}->[$adc] eq $op)){
+ print " - ADD conn=$conn op=$op msgid=$msgid
client=$conn_hash->{$conn}\n";
}
}
for (my $mc = 0; $mc < $modCount; $mc++){
- if ($arrays->{modconn}->[$mc] eq $conn && $arrays->{modop}->[$mc]
eq $op){
- print " - MOD conn=$conn op=$op msgid=$msgid
client=$conn_hash->{$conn}\n";
+ if (($arrays->{modconn}->[$mc] && $arrays->{modop}->[$mc])
&&
+ ($arrays->{modconn}->[$mc] eq $conn &&
$arrays->{modop}->[$mc] eq $op)){
+ print " - MOD conn=$conn op=$op msgid=$msgid
client=$conn_hash->{$conn}\n";
}
}
for (my $cc = 0; $cc < $cmpCount; $cc++){
- if ($arrays->{cmpconn}->[$cc] eq $conn && $arrays->{cmpop}->[$cc]
eq $op){
- print " - CMP conn=$conn op=$op msgid=$msgid
client=$conn_hash->{$conn}\n";
+ if (($arrays->{cmpconn}->[$cc] && $arrays->{cmpop}->[$cc])
&&
+ ($arrays->{cmpconn}->[$cc] eq $conn &&
$arrays->{cmpop}->[$cc] eq $op)){
+ print " - CMP conn=$conn op=$op msgid=$msgid
client=$conn_hash->{$conn}\n";
}
}
for (my $mdc = 0; $mdc < $modrdnCount; $mdc++){
- if ($arrays->{modrdnconn}->[$mdc] eq $conn &&
$arrays->{modrdnop}->[$mdc] eq $op){
+ if (($arrays->{modrdnconn}->[$mdc] &&
$arrays->{modrdnop}->[$mdc]) &&
+ ($arrays->{modrdnconn}->[$mdc] eq $conn &&
$arrays->{modrdnop}->[$mdc] eq $op)){
print " - MODRDN conn=$conn op=$op msgid=$msgid
client=$conn_hash->{$conn}\n";
}
}
for (my $bcb = 0; $bcb < $bindCount; $bcb++){
- if ($arrays->{bindconn}->[$bcb] eq $conn &&
$arrays->{bindop}->[$bcb] eq $op){
+ if (($arrays->{bindconn}->[$bcb] && $arrays->{bindop}->[$bcb])
&&
+ ($arrays->{bindconn}->[$bcb] eq $conn &&
$arrays->{bindop}->[$bcb] eq $op)){
print " - BIND conn=$conn op=$op msgid=$msgid
client=$conn_hash->{$conn}\n";
}
}
for (my $ubc = 0; $ubc < $unbindCount; $ubc++){
- if ($arrays->{unbindconn}->[$ubc] eq $conn &&
$arrays->{unbindop}->[$ubc] eq $op){
+ if (($arrays->{unbindconn}->[$ubc] &&
$arrays->{unbindop}->[$ubc]) &&
+ ($arrays->{unbindconn}->[$ubc] eq $conn &&
$arrays->{unbindop}->[$ubc] eq $op)){
print " - UNBIND conn=$conn op=$op msgid=$msgid
client=$conn_hash->{$conn}\n";
}
}
for (my $ec = 0; $ec < $extopCount; $ec++){
- if ($arrays->{extconn}->[$ec] eq $conn && $arrays->{extop}->[$ec]
eq $op){
- print " - EXT conn=$conn op=$op msgid=$msgid
client=$conn_hash->{$conn}\n";
+ if (($arrays->{extconn}->[$ec] && $arrays->{extop}->[$ec])
&&
+ ($arrays->{extconn}->[$ec] eq $conn &&
$arrays->{extop}->[$ec] eq $op)){
+ print " - EXT conn=$conn op=$op msgid=$msgid
client=$conn_hash->{$conn}\n";
}
}
}
@@ -1485,7 +1502,7 @@ parseLineBind {
return ;
}
$ip = $1;
- if ($_ =~ /conn= *([0-9]+)/i ){
+ if ($_ =~ /conn= *([0-9A-Z]+)/i ){
$connList{$ip} = $connList{$ip} . " $1 ";
}
return;
@@ -1516,7 +1533,7 @@ parseLineBind {
$bindReport{$dn}{"modrdn"} = 0;
$bindReport{$dn}{"failedBind"} = 0;
}
- if ($_ =~ /conn= *([0-9]+)/i) {
+ if ($_ =~ /conn= *([0-9A-Z]+)/i) {
$bindReport{$dn}{"conn"} = $bindReport{$dn}{"conn"} . " $1
";
}
return;
@@ -1547,7 +1564,7 @@ processOpForBindReport
my $op = shift;
my $data = shift;
- if ($data =~ /conn= *([0-9]+)/i) {
+ if ($data =~ /conn= *([0-9A-Z]+)/i) {
foreach my $dn (keys %bindReport){
if ($bindReport{$dn}{"conn"} =~ / $1 /){
$bindReport{$dn}{$op}++;
@@ -1649,48 +1666,48 @@ sub parseLineNormal
$anyAttrs++;
}
if ($verb eq "yes"){
- if ($_ =~ /conn= *([0-9]+)/i){ push @{$arrays->{srchconn}}, $1;}
- if ($_ =~ /op= *([0-9]+)/i){ push @{$arrays->{srchop}}, $1;}
+ if ($_ =~ /conn= *([0-9A-Z]+)/i){ push @{$arrays->{srchconn}}, $1;}
+ if ($_ =~ /op= *([0-9\-]+)/i){ push @{$arrays->{srchop}}, $1;}
}
}
if (m/ DEL/){
$delCount++;
if($reportStats){ inc_stats('del',$s_stats,$m_stats); }
if ($verb eq "yes"){
- if ($_ =~ /conn= *([0-9]+)/i){ push @{$arrays->{delconn}}, $1;}
- if ($_ =~ /op= *([0-9]+)/i){ push @{$arrays->{delop}}, $1;}
+ if ($_ =~ /conn= *([0-9A-Z]+)/i){ push @{$arrays->{delconn}}, $1;}
+ if ($_ =~ /op= *([0-9\-]+)/i){ push @{$arrays->{delop}}, $1;}
}
}
if (m/ MOD dn=/){
$modCount++;
if($reportStats){ inc_stats('mod',$s_stats,$m_stats); }
if ($verb eq "yes"){
- if ($_ =~ /conn= *([0-9]+)/i){ push @{$arrays->{modconn}}, $1;}
- if ($_ =~ /op= *([0-9]+)/i){ push @{$arrays->{modop}}, $1; }
+ if ($_ =~ /conn= *([0-9A-Z]+)/i){ push @{$arrays->{modconn}}, $1;}
+ if ($_ =~ /op= *([0-9\-]+)/i){ push @{$arrays->{modop}}, $1; }
}
}
if (m/ ADD/){
$addCount++;
if($reportStats){ inc_stats('add',$s_stats,$m_stats); }
if ($verb eq "yes"){
- if ($_ =~ /conn= *([0-9]+)/i){ push @{$arrays->{addconn}}, $1; }
- if ($_ =~ /op= *([0-9]+)/i){ push @{$arrays->{addop}}, $1; }
+ if ($_ =~ /conn= *([0-9A-Z]+)/i){ push @{$arrays->{addconn}}, $1; }
+ if ($_ =~ /op= *([0-9\-]+)/i){ push @{$arrays->{addop}}, $1; }
}
}
if (m/ MODRDN/){
$modrdnCount++;
if($reportStats){ inc_stats('modrdn',$s_stats,$m_stats); }
if ($verb eq "yes"){
- if ($_ =~ /conn= *([0-9]+)/i){ push @{$arrays->{modrdnconn}}, $1; }
- if ($_ =~ /op= *([0-9]+)/i){ push @{$arrays->{modrdnop}}, $1; }
+ if ($_ =~ /conn= *([0-9A-Z]+)/i){ push @{$arrays->{modrdnconn}}, $1; }
+ if ($_ =~ /op= *([0-9\-]+)/i){ push @{$arrays->{modrdnop}}, $1; }
}
}
if (m/ CMP dn=/){
$cmpCount++;
if($reportStats){ inc_stats('cmp',$s_stats,$m_stats); }
if ($verb eq "yes" || $usage =~ /g/i){
- if ($_ =~ /conn= *([0-9]+)/i){ push @{$arrays->{cmpconn}}, $1;}
- if ($_ =~ /op= *([0-9]+)/i){ push @{$arrays->{cmpop}}, $1;}
+ if ($_ =~ /conn= *([0-9A-Z]+)/i){ push @{$arrays->{cmpconn}}, $1;}
+ if ($_ =~ /op= *([0-9\-]+)/i){ push @{$arrays->{cmpop}}, $1;}
}
}
if (m/ ABANDON /){
@@ -1699,13 +1716,13 @@ sub parseLineNormal
$allResults++;
if ($_ =~ /targetop= *([0-9a-zA-Z]+)/i ){
push @{$arrays->{targetop}}, $1;
- if ($_ =~ /conn= *([0-9]+)/i){ push @{$arrays->{targetconn}}, $1; }
- if ($_ =~ /msgid= *([0-9]+)/i){ push @{$arrays->{msgid}}, $1; }
+ if ($_ =~ /conn= *([0-9A-Z]+)/i){ push @{$arrays->{targetconn}}, $1; }
+ if ($_ =~ /msgid= *([0-9\-]+)/i){ push @{$arrays->{msgid}}, $1; }
}
}
if (m/ VLV /){
- if ($_ =~ /conn= *([0-9]+)/i){ $vlvconn[$vlvCount] = $1;}
- if ($_ =~ /op= *([0-9]+)/i){ $vlvop[$vlvCount] = $1;}
+ if ($_ =~ /conn= *([0-9A-Z]+)/i){ $vlvconn[$vlvCount] = $1;}
+ if ($_ =~ /op= *([0-9\-]+)/i){ $vlvop[$vlvCount] = $1;}
$vlvCount++;
}
if (m/ authzid=/){
@@ -1792,16 +1809,16 @@ sub parseLineNormal
$tmpp = $1;
$tmpp =~ tr/A-Z/a-z/;
$hashes->{bindlist}->{$tmpp}++;
- if ($_ =~ /conn= *([0-9]+)/i) { push @{$arrays->{bindconn}}, $1;}
- if ($_ =~ /op= *([0-9]+)/i) { push @{$arrays->{bindop}}, $1;}
+ if ($_ =~ /conn= *([0-9A-Z]+)/i) { push @{$arrays->{bindconn}}, $1;}
+ if ($_ =~ /op= *([0-9\-]+)/i) { push @{$arrays->{bindop}}, $1;}
if($usage =~ /f/ || $verb eq "yes"){
push @{$arrays->{binddn}}, $tmpp;
}
} else {
$anonymousBindCount++;
$hashes->{bindlist}->{"Anonymous Binds"}++;
- if ($_ =~ /conn= *([0-9]+)/i) { push @{$arrays->{bindconn}}, $1;}
- if ($_ =~ /op= *([0-9]+)/i) { push @{$arrays->{bindop}}, $1;}
+ if ($_ =~ /conn= *([0-9A-Z]+)/i) { push @{$arrays->{bindconn}}, $1;}
+ if ($_ =~ /op= *([0-9\-]+)/i) { push @{$arrays->{bindop}}, $1;}
push @{$arrays->{binddn}}, "";
inc_stats('anonbind',$s_stats,$m_stats);
}
@@ -1809,17 +1826,18 @@ sub parseLineNormal
if (m/ UNBIND/){
$unbindCount++;
if ($verb eq "yes"){
- if ($_ =~ /conn= *([0-9]+)/i){ push @{$arrays->{unbindconn}}, $1; }
- if ($_ =~ /op= *([0-9]+)/i){ push @{$arrays->{unbindop}}, $1; }
+ if ($_ =~ /conn= *([0-9A-Z]+)/i){ push @{$arrays->{unbindconn}}, $1; }
+ if ($_ =~ /op= *([0-9\-]+)/i){ push @{$arrays->{unbindop}}, $1; }
}
}
if (m/ RESULT err=/ && m/ notes=P/){
$pagedSearchCount++;
}
if (m/ notes=A/){
- if ($_ =~ /conn= *([0-9]+)/i){
+ $con = "";
+ if ($_ =~ /conn= *([0-9A-Z]+)/i){
$con = $1;
- if ($_ =~ /op= *([0-9]+)/i){ $op = $1;}
+ if ($_ =~ /op= *([0-9\-]+)/i){ $op = $1;}
}
for (my $i=0; $i < $vlvCount;$i++){
if ($vlvconn[$i] eq $con && $vlvop[$i] eq $op){ $vlvNotesACount++;
$isVlvNotes="1";}
@@ -1833,8 +1851,8 @@ sub parseLineNormal
if ($usage =~ /u/ || $verb eq "yes"){
if ($isVlvNotes == 0 ){
if ($_ =~ /etime= *([0-9.]+)/i ){ push @{$arrays->{notesAetime}}, $1; }
- if ($_ =~ /conn= *([0-9]+)/i){ push @{$arrays->{notesAconn}}, $1; }
- if ($_ =~ /op= *([0-9]+)/i){ push @{$arrays->{notesAop}}, $1; }
+ if ($_ =~ /conn= *([0-9A-Z]+)/i){ push @{$arrays->{notesAconn}}, $1; }
+ if ($_ =~ /op= *([0-9\-]+)/i){ push @{$arrays->{notesAop}}, $1; }
if ($_ =~ / *([0-9a-z:\/]+)/i){ push @{$arrays->{notesAtime}}, $1; }
if ($_ =~ /nentries= *([0-9]+)/i ){ push @{$arrays->{notesAnentries}}, $1; }
}
@@ -1842,9 +1860,10 @@ sub parseLineNormal
$isVlvNotes = 0;
}
if (m/ notes=U/){
- if ($_ =~ /conn= *([0-9]+)/i){
+ $con = "";
+ if ($_ =~ /conn= *([0-9A-Z]+)/i){
$con = $1;
- if ($_ =~ /op= *([0-9]+)/i){ $op = $1;}
+ if ($_ =~ /op= *([0-9\-]+)/i){ $op = $1;}
}
for (my $i=0; $i < $vlvCount;$i++){
if ($vlvconn[$i] eq $con && $vlvop[$i] eq $op){ $vlvNotesUCount++;
$isVlvNotes="1";}
@@ -1858,8 +1877,8 @@ sub parseLineNormal
if ($usage =~ /u/ || $verb eq "yes"){
if ($isVlvNotes == 0 ){
if ($_ =~ /etime= *([0-9.]+)/i ){ push @{$arrays->{notesUetime}}, $1; }
- if ($_ =~ /conn= *([0-9]+)/i){ push @{$arrays->{notesUconn}}, $1; }
- if ($_ =~ /op= *([0-9]+)/i){ push @{$arrays->{notesUop}}, $1; }
+ if ($_ =~ /conn= *([0-9A-Z]+)/i){ push @{$arrays->{notesUconn}}, $1; }
+ if ($_ =~ /op= *([0-9\-]+)/i){ push @{$arrays->{notesUop}}, $1; }
if ($_ =~ / *([0-9a-z:\/]+)/i){ push @{$arrays->{notesUtime}}, $1; }
if ($_ =~ /nentries= *([0-9]+)/i ){ push @{$arrays->{notesUnentries}}, $1; }
}
@@ -1922,14 +1941,14 @@ sub parseLineNormal
}
$ip = $1;
$hashes->{ip_hash}->{$ip}++;
- if ($_ =~ /conn= *([0-9]+)/i ){
+ if ($_ =~ /conn= *([0-9A-Z]+)/i ){
if ($exc ne "yes"){
$hashes->{conn_hash}->{$1} = $ip;
}
}
}
if (m/- A1/){
- if ($_ =~ /conn= *([0-9]+)/i) {
+ if ($_ =~ /conn= *([0-9A-Z]+)/i) {
$exc = "no";
$ip = getIPfromConn($1);
if ($ip eq ""){$ip = "Unknown_Host";}
@@ -1944,7 +1963,7 @@ sub parseLineNormal
}
}
if (m/- B1/){
- if ($_ =~ /conn= *([0-9]+)/i) {
+ if ($_ =~ /conn= *([0-9A-Z]+)/i) {
$exc = "no";
$ip = getIPfromConn($1);
if ($ip eq ""){$ip = "Unknown_Host";}
@@ -1959,7 +1978,7 @@ sub parseLineNormal
}
}
if (m/- B4/){
- if ($_ =~ /conn= *([0-9]+)/i) {
+ if ($_ =~ /conn= *([0-9A-Z]+)/i) {
$exc = "no";
$ip = getIPfromConn($1);
if ($ip eq ""){$ip = "Unknown_Host";}
@@ -1974,7 +1993,7 @@ sub parseLineNormal
}
}
if (m/- T1/){
- if ($_ =~ /conn= *([0-9]+)/i) {
+ if ($_ =~ /conn= *([0-9A-Z]+)/i) {
$exc = "no";
$ip = getIPfromConn($1);
if ($ip eq ""){$ip = "Unknown_Host";}
@@ -1989,7 +2008,7 @@ sub parseLineNormal
}
}
if (m/- T2/){
- if ($_ =~ /conn= *([0-9]+)/i) {
+ if ($_ =~ /conn= *([0-9A-Z]+)/i) {
$exc = "no";
$ip = getIPfromConn($1);
if ($ip eq ""){$ip = "Unknown_Host";}
@@ -2004,7 +2023,7 @@ sub parseLineNormal
}
}
if (m/- B2/){
- if ($_ =~ /conn= *([0-9]+)/i) {
+ if ($_ =~ /conn= *([0-9A-Z]+)/i) {
$exc = "no";
$ip = getIPfromConn($1);
$maxBerSizeCount++;
@@ -2020,7 +2039,7 @@ sub parseLineNormal
}
}
if (m/- B3/){
- if ($_ =~ /conn= *([0-9]+)/i) {
+ if ($_ =~ /conn= *([0-9A-Z]+)/i) {
$exc = "no";
$ip = getIPfromConn($1);
if ($ip eq ""){$ip = "Unknown_Host";}
@@ -2035,7 +2054,7 @@ sub parseLineNormal
}
}
if (m/- R1/){
- if ($_ =~ /conn= *([0-9]+)/i) {
+ if ($_ =~ /conn= *([0-9A-Z]+)/i) {
$exc = "no";
$ip = getIPfromConn($1);
if ($ip eq ""){$ip = "Unknown_Host";}
@@ -2050,7 +2069,7 @@ sub parseLineNormal
}
}
if (m/- P1/){
- if ($_ =~ /conn= *([0-9]+)/i) {
+ if ($_ =~ /conn= *([0-9A-Z]+)/i) {
$exc = "no";
$ip = getIPfromConn($1);
if ($ip eq ""){$ip = "Unknown_Host";}
@@ -2065,7 +2084,7 @@ sub parseLineNormal
}
}
if (m/- P2/){
- if ($_ =~ /conn= *([0-9]+)/i) {
+ if ($_ =~ /conn= *([0-9A-Z]+)/i) {
$exc = "no";
$ip = getIPfromConn($1);
if ($ip eq ""){$ip = "Unknown_Host";}
@@ -2080,7 +2099,7 @@ sub parseLineNormal
}
}
if (m/- U1/){
- if ($_ =~ /conn= *([0-9]+)/i) {
+ if ($_ =~ /conn= *([0-9A-Z]+)/i) {
$exc = "no";
$ip = getIPfromConn($1);
if ($ip eq ""){$ip = "Unknown_Host";}
@@ -2112,8 +2131,8 @@ sub parseLineNormal
if ($_ =~ /oid=\" *([0-9\.]+)/i ){ $hashes->{oid}->{$1}++; }
if ($1 && $1 eq $startTLSoid){$startTLSCount++;}
if ($verb eq "yes"){
- if ($_ =~ /conn= *([0-9]+)/i){ push @{$arrays->{extconn}}, $1; }
- if ($_ =~ /op= *([0-9]+)/i){ push @{$arrays->{extop}}, $1; }
+ if ($_ =~ /conn= *([0-9A-Z]+)/i){ push @{$arrays->{extconn}}, $1; }
+ if ($_ =~ /op= *([0-9\-]+)/i){ push @{$arrays->{extop}}, $1; }
}
}
if (($usage =~ /l/ || $verb eq "yes") and / SRCH /){
@@ -2123,15 +2142,15 @@ sub parseLineNormal
$tmpp =~ tr/A-Z/a-z/;
$tmpp =~ s/\\22/\"/g;
$hashes->{filter}->{$tmpp}++;
- if ($_ =~ /conn= *([0-9]+)/i) { $filterConn = $1; }
- if ($_ =~ /op= *([0-9]+)/i) { $filterOp = $1; }
+ if ($_ =~ /conn= *([0-9A-Z]+)/i) { $filterConn = $1; }
+ if ($_ =~ /op= *([0-9\-]+)/i) { $filterOp = $1; }
} elsif (/ SRCH / && $_ =~ /filter=\"(.*)\"/i){
$tmpp = $1;
$tmpp =~ tr/A-Z/a-z/;
$tmpp =~ s/\\22/\"/g;
$hashes->{filter}->{$tmpp}++;
- if ($_ =~ /conn= *([0-9]+)/i) { $filterConn = $1; }
- if ($_ =~ /op= *([0-9]+)/i) { $filterOp = $1; }
+ if ($_ =~ /conn= *([0-9A-Z]+)/i) { $filterConn = $1; }
+ if ($_ =~ /op= *([0-9\-]+)/i) { $filterOp = $1; }
}
$filterCount++;
if($usage =~ /u/ || $verb eq "yes"){
@@ -2157,11 +2176,11 @@ sub parseLineNormal
if ($_ =~ /scope= *([0-9]+)/i) {
$scopeVal = $1;
}
- if ($_ =~ /conn= *([0-9]+)/i) {
+ if ($_ =~ /conn= *([0-9A-Z]+)/i) {
$baseConn = $1;
$scopeConn = $1;
}
- if ($_ =~ /op= *([0-9]+)/i) {
+ if ($_ =~ /op= *([0-9\-]+)/i) {
$baseOp = $1;
$scopeOp = $1;
}
@@ -2170,9 +2189,9 @@ sub parseLineNormal
push @{$arrays->{baseval}}, $tmpp;
push @{$arrays->{baseconn}}, $baseConn;
push @{$arrays->{baseop}}, $baseOp;
- push @{$arrays->{scopeval}}, $scopeVal;
- push @{$arrays->{scopeconn}}, $scopeConn;
- push @{$arrays->{scopeop}}, $scopeOp;
+ push @{$arrays->{scopeval}}, $scopeTxt[$scopeVal];
+ push @{$arrays->{scopeconn}}, $scopeConn;
+ push @{$arrays->{scopeop}}, $scopeOp;
}
$baseCount++;
$scopeCount++;
@@ -2191,12 +2210,12 @@ sub parseLineNormal
$ds6x = "true";
$badPwdCount++;
} elsif (/ err=49 tag=/ ){
- if ($_ =~ /conn= *([0-9]+)/i ){
+ if ($_ =~ /conn= *([0-9A-Z]+)/i ){
push @{$arrays->{badpwdconn}}, $1;
$ip = getIPfromConn($1);
$badPwdCount++;
}
- if ($_ =~ /op= *([0-9]+)/i ){
+ if ($_ =~ /op= *([0-9\-]+)/i ){
push @{$arrays->{badpwdop}}, $1;
}
push @{$arrays->{badpwdip}}, $ip;
commit 7a107bdb67dad58728977b3f410df1d94c6cdb91
Author: Rich Megginson <rmeggins(a)redhat.com>
Date: Tue Jul 2 14:38:49 2013 -0600
Ticket #47387 - improve logconv.pl performance with large access logs
https://fedorahosted.org/389/ticket/47387
Reviewed by: mreynolds (Thanks!)
Branch: master
Fix Description: Fix some additional uninitialized variable warnings
Platforms tested: RHEL6 x86_64
Flag Day: no
Doc impact: no
(cherry picked from commit 8a23f5e0af41291d28c4ce7251d9bb2e94a5994c)
diff --git a/ldap/admin/src/logconv.pl b/ldap/admin/src/logconv.pl
index b628d03..ec0fdf5 100755
--- a/ldap/admin/src/logconv.pl
+++ b/ldap/admin/src/logconv.pl
@@ -673,7 +673,7 @@ if ($verb eq "yes" || $usage =~ /u/){
my $notesCount = "1";
my $unindexedIp;
- for (my $n = 0; $n <= scalar(@{$notesEtime}); $n++){
+ for (my $n = 0; $n < scalar(@{$notesEtime}); $n++){
if($conn_hash->{$notesConn->[$n]} eq ""){
$unindexedIp = "?";
} else {
@@ -726,7 +726,7 @@ if ($verb eq "yes" || $usage =~ /u/){
my $notesCount = "1";
my $unindexedIp;
- for (my $n = 0; $n <= scalar(@{$notesEtime}); $n++){
+ for (my $n = 0; $n < scalar(@{$notesEtime}); $n++){
if($conn_hash->{$notesConn->[$n]} eq ""){
$unindexedIp = "?";
} else {
@@ -1821,7 +1821,7 @@ sub parseLineNormal
$con = $1;
if ($_ =~ /op= *([0-9]+)/i){ $op = $1;}
}
- for (my $i=0; $i <= $vlvCount;$i++){
+ for (my $i=0; $i < $vlvCount;$i++){
if ($vlvconn[$i] eq $con && $vlvop[$i] eq $op){ $vlvNotesACount++;
$isVlvNotes="1";}
}
if($isVlvNotes == 0){
@@ -1846,7 +1846,7 @@ sub parseLineNormal
$con = $1;
if ($_ =~ /op= *([0-9]+)/i){ $op = $1;}
}
- for (my $i=0; $i <= $vlvCount;$i++){
+ for (my $i=0; $i < $vlvCount;$i++){
if ($vlvconn[$i] eq $con && $vlvop[$i] eq $op){ $vlvNotesUCount++;
$isVlvNotes="1";}
}
if($isVlvNotes == 0){
commit 8e35cc8b418bc46fbeb28f4378d24f9c2cab0353
Author: Rich Megginson <rmeggins(a)redhat.com>
Date: Mon Jun 10 20:04:20 2013 -0600
Ticket #47387 - improve logconv.pl performance with large access logs
https://fedorahosted.org/389/ticket/47387
Reviewed by: mreynolds (Thanks!)
Branch: master
Fix Description: The primary fix is to use tied hashes and arrays backed by
DB_File database files. Hashes use DB_HASH and arrays use DB_RECNO. These
fixes cut down the time by a factor of 10 or more, and considerably reduce
the size of the disk files. There is still room for optimization as given
by the Devel::NYTProf package, but this should at least give us acceptable
performance.
I also did some perl "linting" - running with use warnings and use strict -
which revealed a lot of code which was cleaned up.
Platforms tested: RHEL6 x86_64
Flag Day: no
Doc impact: no
diff --git a/ldap/admin/src/logconv.pl b/ldap/admin/src/logconv.pl
index 8ae72da..b628d03 100755
--- a/ldap/admin/src/logconv.pl
+++ b/ldap/admin/src/logconv.pl
@@ -43,9 +43,14 @@
#
# Check for usage
#
+use strict;
+use warnings;
+use warnings 'untie';
use Time::Local;
use IO::File;
use Getopt::Long;
+use DB_File;
+use sigtrap qw(die normal-signals);
Getopt::Long::Configure ("bundling");
Getopt::Long::Configure ("permute");
@@ -60,19 +65,43 @@ if ($#ARGV < 0){;
# #
#######################################
-$file_count = 0;
-$arg_count = 0;
-$logversion = "7.0";
-$sizeCount = "20";
-$startFlag = 0;
-$startTime = 0;
-$endFlag = 0;
-$endTime = 0;
-$reportStats = "";
-$dataLocation = "/tmp";
-$startTLSoid = "1.3.6.1.4.1.1466.20037";
-$s_stats = new_stats_block( );
-$m_stats = new_stats_block( );
+my $file_count = 0;
+my $arg_count = 0;
+my $logversion = "7.0";
+my $sizeCount = "20";
+my $startFlag = 0;
+my $startTime = 0;
+my $endFlag = 0;
+my $endTime = 0;
+my $reportStats = "";
+my $dataLocation = "/tmp";
+my $startTLSoid = "1.3.6.1.4.1.1466.20037";
+my $s_stats = new_stats_block( );
+my $m_stats = new_stats_block( );
+my $verb = "no";
+my @excludeIP;
+my $xi = 0;
+my $bindReportDN;
+my $usage = "";
+my @latency;
+my @openConnection;
+my @errorCode;
+my @errtext;
+my @errornum;
+my @errornum2;
+my $ds6x = "false";
+my $connCodeCount = 0;
+my %connList;
+my %bindReport;
+my @vlvconn;
+my @vlvop;
+my @start_time_of_connection;
+my @end_time_of_connection;
+my @fds;
+my $fdds = 0;
+my $reportBinds = "no";
+my $rootDN = "";
+my $needCleanup = 0;
GetOptions(
'd|rootDN=s' => \$rootDN,
@@ -129,6 +158,7 @@ if($rootDN eq ""){
#
# get the logs
#
+my @files = ();
while($arg_count <= $#ARGV){
$files[$file_count] = $ARGV[$arg_count];
$file_count++;
@@ -155,127 +185,93 @@ if ($sizeCount eq "all"){$sizeCount =
"100000";}
print "\nAccess Log Analyzer $logversion\n";
print "\nCommand: logconv.pl @ARGV\n\n";
-$rootDNBindCount = 0;
-$anonymousBindCount = 0;
-$unindexedSrchCountNotesA = 0;
-$unindexedSrchCountNotesU = 0;
-$vlvNotesACount= 0;
-$vlvNotesUCount= 0;
-$srchCount = 0;
-$fdTaken = 0;
-$fdReturned = 0;
-$highestFdTaken = 0;
-$unbindCount = 0;
-$cmpCount = 0;
-$modCount = 0;
-$delCount = 0;
-$addCount = 0;
-$modrdnCount = 0;
-$abandonCount = 0;
-$extopCount = 0;
-$vlvCount = 0;
-$errorCount = 0;
-$proxiedAuthCount = 0;
-$serverRestartCount = 0;
-$resourceUnavailCount = 0;
-$brokenPipeCount = 0;
-$v2BindCount = 0;
-$v3BindCount = 0;
-$vlvSortCount = 0;
-$connResetByPeerCount = 0;
-$isVlvNotes = 0;
-$successCount = 0;
-$sslCount = 0;
-$sslClientBindCount = 0;
-$sslClientFailedCount = 0;
-$objectclassTopCount= 0;
-$pagedSearchCount = 0;
-$bindCount = 0;
-$filterCount = 0;
-$baseCount = 0;
-$scopeCount = 0;
-$allOps = 0;
-$allResults = 0;
-$badPwdCount = 0;
-$saslBindCount = 0;
-$internalOpCount = 0;
-$entryOpCount = 0;
-$referralCount = 0;
-$anyAttrs = 0;
-$persistentSrchCount = 0;
-$maxBerSizeCount = 0;
-$connectionCount = 0;
-$timerange = 0;
-$simConnection = 0;
-$maxsimConnection = 0;
-$firstFile = 1;
-$elapsedDays = 0;
-$logCount = 0;
-$startTLSCount = 0;
-$ldapiCount = 0;
-$autobindCount = 0;
-$limit = 25000; # number of lines processed to trigger output
-
-# hash files
-$ATTR = "$dataLocation/attr.logconv";
-$RC = "$dataLocation/rc.logconv";
-$SRC = "$dataLocation/src.logconv";
-$RSRC = "$dataLocation/rsrc.logconv";
-$EXCOUNT = "$dataLocation/excount.logconv";
-$CONN_HASH = "$dataLocation/conn_hash.logconv";
-$IP_HASH = "$dataLocation/ip_hash.logconv";
-$CONNCOUNT = "$dataLocation/conncount.logconv";
-$NENTRIES = "$dataLocation/nentries.logconv";
-$FILTER = "$dataLocation/filter.logconv";
-$BASE = "$dataLocation/base.logconv";
-$DS6XBADPWD = "$dataLocation/ds6xbadpwd.logconv";
-$SASLMECH = "$dataLocation/saslmech.logconv";
-$BINDLIST = "$dataLocation/bindlist.logconv";
-$ETIME = "$dataLocation/etime.logconv";
-$OID = "$dataLocation/oid.logconv";
-
-# array files
-$SRCH_CONN = "$dataLocation/srchconn.logconv";
-$SRCH_OP = "$dataLocation/srchop.logconv";
-$DEL_CONN = "$dataLocation/delconn.logconv";
-$DEL_OP = "$dataLocation/delop.logconv";
-$MOD_CONN = "$dataLocation/modconn.logconv";
-$MOD_OP = "$dataLocation/modop.logconv";
-$ADD_CONN = "$dataLocation/addconn.logconv";
-$ADD_OP = "$dataLocation/addop.logconv";
-$MODRDN_CONN = "$dataLocation/modrdnconn.logconv";
-$MODRDN_OP = "$dataLocation/modrdnop.logconv";
-$CMP_CONN = "$dataLocation/cmpconn.logconv";
-$CMP_OP = "$dataLocation/cmpop.logconv";
-$TARGET_CONN = "$dataLocation/targetconn.logconv";
-$TARGET_OP = "$dataLocation/targetop.logconv";
-$MSGID = "$dataLocation/msgid.logconv";
-$BIND_CONN = "$dataLocation/bindconn.logconv";
-$BIND_OP = "$dataLocation/bindop.logconv";
-$UNBIND_CONN = "$dataLocation/unbindconn.logconv";
-$UNBIND_OP = "$dataLocation/unbindop.logconv";
-$EXT_CONN = "$dataLocation/extconn.logconv";
-$EXT_OP = "$dataLocation/extop.logconv";
-$NOTES_A_ETIME = "$dataLocation/notesAetime.logconv";
-$NOTES_A_CONN = "$dataLocation/notesAconn.logconv";
-$NOTES_A_OP = "$dataLocation/notesAop.logconv";
-$NOTES_A_TIME = "$dataLocation/notesAtime.logconv";
-$NOTES_A_NENTRIES = "$dataLocation/notesAnentries.logconv";
-$NOTES_U_ETIME = "$dataLocation/notesUetime.logconv";
-$NOTES_U_CONN = "$dataLocation/notesUconn.logconv";
-$NOTES_U_OP = "$dataLocation/notesUop.logconv";
-$NOTES_U_TIME = "$dataLocation/notesUtime.logconv";
-$NOTES_U_NENTRIES = "$dataLocation/notesUnentries.logconv";
-$BADPWDCONN = "$dataLocation/badpwdconn.logconv";
-$BADPWDOP = "$dataLocation/badpwdop.logconv";
-$BADPWDIP = "$dataLocation/badpwdip.logconv";
-
-# info files
-$BINDINFO = "$dataLocation/bindinfo.logconv";
-$BASEINFO = "$dataLocation/baseinfo.logconv";
-$FILTERINFO = "$dataLocation/filterinfo.logconv";
-$SCOPEINFO = "$dataLocation/scopeinfo.logconv";
-
+my $rootDNBindCount = 0;
+my $anonymousBindCount = 0;
+my $unindexedSrchCountNotesA = 0;
+my $unindexedSrchCountNotesU = 0;
+my $vlvNotesACount= 0;
+my $vlvNotesUCount= 0;
+my $srchCount = 0;
+my $fdTaken = 0;
+my $fdReturned = 0;
+my $highestFdTaken = 0;
+my $unbindCount = 0;
+my $cmpCount = 0;
+my $modCount = 0;
+my $delCount = 0;
+my $addCount = 0;
+my $modrdnCount = 0;
+my $abandonCount = 0;
+my $extopCount = 0;
+my $vlvCount = 0;
+my $errorCount = 0;
+my $proxiedAuthCount = 0;
+my $serverRestartCount = 0;
+my $resourceUnavailCount = 0;
+my $brokenPipeCount = 0;
+my $v2BindCount = 0;
+my $v3BindCount = 0;
+my $vlvSortCount = 0;
+my $connResetByPeerCount = 0;
+my $isVlvNotes = 0;
+my $successCount = 0;
+my $sslCount = 0;
+my $sslClientBindCount = 0;
+my $sslClientFailedCount = 0;
+my $objectclassTopCount= 0;
+my $pagedSearchCount = 0;
+my $bindCount = 0;
+my $filterCount = 0;
+my $baseCount = 0;
+my $scopeCount = 0;
+my $allOps = 0;
+my $allResults = 0;
+my $badPwdCount = 0;
+my $saslBindCount = 0;
+my $internalOpCount = 0;
+my $entryOpCount = 0;
+my $referralCount = 0;
+my $anyAttrs = 0;
+my $persistentSrchCount = 0;
+my $maxBerSizeCount = 0;
+my $connectionCount = 0;
+my $timerange = 0;
+my $simConnection = 0;
+my $maxsimConnection = 0;
+my $firstFile = 1;
+my $elapsedDays = 0;
+my $logCount = 0;
+my $startTLSCount = 0;
+my $ldapiCount = 0;
+my $autobindCount = 0;
+my $limit = 25000; # number of lines processed to trigger output
+
+my @removefiles = ();
+
+my @conncodes = qw(A1 B1 B4 T1 T2 B2 B3 R1 P1 P2 U1);
+my %conn = ();
+map {$conn{$_} = $_} @conncodes;
+
+# hash db-backed hashes
+my @hashnames = qw(attr rc src rsrc excount conn_hash ip_hash conncount nentries
+ filter base ds6xbadpwd saslmech bindlist etime oid);
+# need per connection code ip address counts - so use a hash table
+# for each connection code - key is ip, val is count
+push @hashnames, @conncodes;
+my $hashes = openHashFiles($dataLocation, @hashnames);
+
+# recno db-backed arrays/lists
+my @arraynames = qw(srchconn srchop delconn delop modconn modop addconn addop modrdnconn
modrdnop
+ cmpconn cmpop targetconn targetop msgid bindconn bindop binddn
unbindconn unbindop
+ extconn extop notesAetime notesAconn notesAop notesAtime
notesAnentries
+ notesUetime notesUconn notesUop notesUtime notesUnentries badpwdconn
+ badpwdop badpwdip baseval baseconn baseop scopeval scopeconn scopeop
+ filterval filterconn filterop);
+my $arrays = openArrayFiles($dataLocation, @arraynames);
+
+$needCleanup = 1;
+
+my @err;
$err[0] = "Successful Operations\n";
$err[1] = "Operations Error(s)\n";
$err[2] = "Protocal Errors\n";
@@ -338,19 +334,7 @@ $err[95] = "More Results To Return\n";
$err[96] = "Client Loop\n";
$err[97] = "Referral Limit Exceeded\n";
-
-$conn{"A1"} = "A1";
-$conn{"B1"} = "B1";
-$conn{"B4"} = "B4";
-$conn{"T1"} = "T1";
-$conn{"T2"} = "T2";
-$conn{"B2"} = "B2";
-$conn{"B3"} = "B3";
-$conn{"R1"} = "R1";
-$conn{"P1"} = "P1";
-$conn{"P2"} = "P2";
-$conn{"U1"} = "U1";
-
+my %connmsg;
$connmsg{"A1"} = "Client Aborted Connections";
$connmsg{"B1"} = "Bad Ber Tag Encountered";
$connmsg{"B4"} = "Server failed to flush data (response) back to
Client";
@@ -363,7 +347,7 @@ $connmsg{"P1"} = "Plugin";
$connmsg{"P2"} = "Poll";
$connmsg{"U1"} = "Cleanly Closed Connections";
-%monthname = (
+my %monthname = (
"Jan" => 0,
"Feb" => 1,
"Mar" => 2,
@@ -379,7 +363,17 @@ $connmsg{"U1"} = "Cleanly Closed Connections";
);
-openDataFiles();
+my $linesProcessed;
+my $lineBlockCount;
+my $cursize = 0;
+sub statusreport {
+ if ($lineBlockCount > $limit) {
+ my $curpos = tell(LOG);
+ my $percent = $curpos/$cursize*100.0;
+ print sprintf "%10d Lines Processed %12d of %12d bytes
(%.3f%%)\n",--$linesProcessed,$curpos,$cursize,$percent;
+ $lineBlockCount = 0;
+ }
+}
##########################################
# #
@@ -394,6 +388,7 @@ print "Processing $file_count Access Log(s)...\n\n";
#print "Filename\t\t\t Total Lines\n";
#print "--------------------------------------------------\n";
+my $skipFirstFile = 0;
if ($file_count > 1 && $files[0] =~ /\/access$/){
$files[$file_count] = $files[0];
$file_count++;
@@ -401,25 +396,30 @@ if ($file_count > 1 && $files[0] =~ /\/access$/){
}
$logCount = $file_count;
-for ($count=0; $count < $file_count; $count++){
+my $logline;
+my $totalLineCount = 0;
+
+for (my $count=0; $count < $file_count; $count++){
# we moved access to the end of the list, so if its the first file skip it
if($file_count > 1 && $count == 0 && $skipFirstFile == 1){
next;
}
- $logsize = `wc -l $files[$count]`;
- $logsize =~ /([0-9]+)/;
$linesProcessed = 0; $lineBlockCount = 0;
$logCount--;
+ my $logCountStr;
if($logCount < 10 ){
# add a zero for formatting purposes
$logCountStr = "0" . $logCount;
} else {
$logCountStr = $logCount;
}
- print sprintf "[%s] %-30s\tlines: %7s\n",$logCountStr, $files[$count], $1;
+ my ($dev,$ino,$mode,$nlink,$uid,$gid,$rdev,$atime,$mtime,$ctime,$blksize,$blocks);
+ ($dev,$ino,$mode,$nlink,$uid,$gid,$rdev,$cursize,
+ $atime,$mtime,$ctime,$blksize,$blocks) = stat($files[$count]);
+ print sprintf "[%s] %-30s\tsize (bytes): %12s\n",$logCountStr,
$files[$count], $cursize;
open(LOG,"$files[$count]") or do { openFailed($!, $files[$count]) };
- $firstline = "yes";
+ my $firstline = "yes";
while(<LOG>){
unless ($endFlag) {
if ($firstline eq "yes"){
@@ -442,7 +442,7 @@ for ($count=0; $count < $file_count; $count++){
print_stats_block( $s_stats );
print_stats_block( $m_stats );
$totalLineCount = $totalLineCount + $linesProcessed;
- if($linesProcessed => $limit){print sprintf " %10s Lines
Processed\n\n",--$linesProcessed;}
+ statusreport();
}
print "\n\nTotal Log Lines Analysed: " . ($totalLineCount - 1) .
"\n";
@@ -457,9 +457,11 @@ $allOps = $srchCount + $modCount + $addCount + $cmpCount + $delCount
+ $modrdnCo
# if we are using startTime & endTime then we need to clean it up for our processing
+my $start;
if($startTime){
if ($start =~ / *([0-9a-z:\/]+)/i){$start=$1;}
}
+my $end;
if($endTime){
if ($end =~ / *([0-9a-z:\/]+)/i){$end =$1;}
}
@@ -468,8 +470,10 @@ if($endTime){
# Get the start time in seconds
#
-$logStart = $start;
-
+my $logStart = $start;
+my $logDate;
+my @dateComps;
+my ($timeMonth, $timeDay, $timeYear, $dateTotal);
if ($logStart =~ / *([0-9A-Z\/]+)/i ){
$logDate = $1;
@dateComps = split /\//, $logDate;
@@ -481,6 +485,9 @@ if ($logStart =~ / *([0-9A-Z\/]+)/i ){
$dateTotal = $timeMonth + $timeDay + $timeYear;
}
+my $logTime;
+my @timeComps;
+my ($timeHour, $timeMinute, $timeSecond, $timeTotal);
if ($logStart =~ / *(:[0-9:]+)/i ){
$logTime = $1;
@timeComps = split /:/, $logTime;
@@ -491,14 +498,14 @@ if ($logStart =~ / *(:[0-9:]+)/i ){
$timeTotal = $timeHour + $timeMinute + $timeSecond;
}
-$startTotal = $timeTotal + $dateTotal;
+my $startTotal = $timeTotal + $dateTotal;
#
# Get the end time in seconds
#
-$logEnd = $end;
-
+my $logEnd = $end;
+my ($endDay, $endMonth, $endYear, $endTotal);
if ($logEnd =~ / *([0-9A-Z\/]+)/i ){
$logDate = $1;
@dateComps = split /\//, $logDate;
@@ -506,10 +513,11 @@ if ($logEnd =~ / *([0-9A-Z\/]+)/i ){
$endDay = $dateComps[0] *3600 * 24;
$endMonth = 1 + $monthname{$dateComps[1]};
$endMonth = $endMonth * 3600 * 24 * 30;
- $endYear = $endTotal + $dateComps[2] *365 * 3600 * 24 ;
+ $endYear = $dateComps[2] *365 * 3600 * 24 ;
$dateTotal = $endDay + $endMonth + $endYear;
}
+my ($endHour, $endMinute, $endSecond);
if ($logEnd =~ / *(:[0-9:]+)/i ){
$logTime = $1;
@timeComps = split /:/, $logTime;
@@ -525,8 +533,8 @@ $endTotal = $timeTotal + $dateTotal;
#
# Tally the numbers
#
-$totalTimeInSecs = $endTotal - $startTotal;
-$remainingTimeInSecs = $totalTimeInSecs;
+my $totalTimeInSecs = $endTotal - $startTotal;
+my $remainingTimeInSecs = $totalTimeInSecs;
#
# Calculate the elapsed time
@@ -540,33 +548,21 @@ while(($remainingTimeInSecs - 86400) > 0){
}
# hours
+my $elapsedHours = 0;
while(($remainingTimeInSecs - 3600) > 0){
$elapsedHours++;
$remainingTimeInSecs = $remainingTimeInSecs - 3600;
}
# minutes
+my $elapsedMinutes = 0;
while($remainingTimeInSecs - 60 > 0){
$elapsedMinutes++;
$remainingTimeInSecs = $remainingTimeInSecs - 60;
}
# seconds
-$elapsedSeconds = $remainingTimeInSecs;
-
-# Initialize empty values
-if($elapsedHours eq ""){
- $elapsedHours = "0";
-}
-if($elapsedMinutes eq ""){
- $elapsedMinutes = "0";
-}
-if($elapsedSeconds eq ""){
- $elapsedSeconds = "0";
-}
-
-&closeDataFiles();
-
+my $elapsedSeconds = $remainingTimeInSecs;
#####################################
# #
@@ -605,20 +601,21 @@ print " - LDAPI Connections: $ldapiCount\n";
print "Peak Concurrent Connections: $maxsimConnection\n";
print "Total Operations: $allOps\n";
print "Total Results: $allResults\n";
+my ($perf, $tmp);
if ($allOps ne "0"){
- print sprintf "Overall Performance: %.1f%\n\n" , ($perf = ($tmp =
($allResults / $allOps)*100) > 100 ? 100.0 : $tmp) ;
+ print sprintf "Overall Performance: %.1f%%\n\n" , ($perf = ($tmp =
($allResults / $allOps)*100) > 100 ? 100.0 : $tmp) ;
}
else {
print "Overall Performance: No Operations to evaluate\n\n";
}
-$searchStat = sprintf "(%.2f/sec) (%.2f/min)\n",($srchCount /
$totalTimeInSecs), $srchCount / ($totalTimeInSecs/60);
-$modStat = sprintf "(%.2f/sec) (%.2f/min)\n",$modCount / $totalTimeInSecs,
$modCount/($totalTimeInSecs/60);
-$addStat = sprintf "(%.2f/sec) (%.2f/min)\n",$addCount/$totalTimeInSecs,
$addCount/($totalTimeInSecs/60);
-$deleteStat = sprintf "(%.2f/sec) (%.2f/min)\n",$delCount/$totalTimeInSecs,
$delCount/($totalTimeInSecs/60);
-$modrdnStat = sprintf "(%.2f/sec) (%.2f/min)\n",$modrdnCount/$totalTimeInSecs,
$modrdnCount/($totalTimeInSecs/60);
-$compareStat = sprintf "(%.2f/sec) (%.2f/min)\n",$cmpCount/$totalTimeInSecs,
$cmpCount/($totalTimeInSecs/60);
-$bindCountStat = sprintf "(%.2f/sec)
(%.2f/min)\n",$bindCount/$totalTimeInSecs, $bindCount/($totalTimeInSecs/60);
+my $searchStat = sprintf "(%.2f/sec) (%.2f/min)\n",($srchCount /
$totalTimeInSecs), $srchCount / ($totalTimeInSecs/60);
+my $modStat = sprintf "(%.2f/sec) (%.2f/min)\n",$modCount / $totalTimeInSecs,
$modCount/($totalTimeInSecs/60);
+my $addStat = sprintf "(%.2f/sec) (%.2f/min)\n",$addCount/$totalTimeInSecs,
$addCount/($totalTimeInSecs/60);
+my $deleteStat = sprintf "(%.2f/sec) (%.2f/min)\n",$delCount/$totalTimeInSecs,
$delCount/($totalTimeInSecs/60);
+my $modrdnStat = sprintf "(%.2f/sec)
(%.2f/min)\n",$modrdnCount/$totalTimeInSecs, $modrdnCount/($totalTimeInSecs/60);
+my $compareStat = sprintf "(%.2f/sec)
(%.2f/min)\n",$cmpCount/$totalTimeInSecs, $cmpCount/($totalTimeInSecs/60);
+my $bindCountStat = sprintf "(%.2f/sec)
(%.2f/min)\n",$bindCount/$totalTimeInSecs, $bindCount/($totalTimeInSecs/60);
format STDOUT =
Searches: @<<<<<<<<<<<<
@<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
@@ -658,148 +655,110 @@ print "Unindexed Searches:
$unindexedSrchCountNotesA\n";
print "Unindexed Components: $unindexedSrchCountNotesU\n";
if ($verb eq "yes" || $usage =~ /u/){
if ($unindexedSrchCountNotesA > 0){
- %conn_hash = getHashFromFile($CONN_HASH);
- @notesConn = getArrayFromFile($NOTES_A_CONN);
- @notesOp = getArrayFromFile($NOTES_A_OP);
- @notesEtime = getArrayFromFile($NOTES_A_ETIME);
- @notesTime = getArrayFromFile($NOTES_A_TIME);
- @notesNentries = getArrayFromFile($NOTES_A_NENTRIES);
- getInfoArraysFromFile($BASEINFO);
- @base_val = @fileArray1;
- @base_conn = @fileArray2;
- @base_op = @fileArray3;
- getInfoArraysFromFile($SCOPEINFO);
- @scope_val = @fileArray1;
- @scope_conn = @fileArray2;
- @scope_op = @fileArray3;
- getInfoArraysFromFile($FILTERINFO);
- @filter_val = @fileArray1;
- @filter_conn = @fileArray2;
- @filter_op = @fileArray3;
-
- $notesCount = "1";
- for ($n = 0; $n <= $#notesEtime; $n++){
- @alreadyseenDN = ();
- if($conn_hash{$notesConn[$n]} eq ""){
+ my $conn_hash = $hashes->{conn_hash};
+ my $notesConn = $arrays->{notesAconn};
+ my $notesOp = $arrays->{notesAop};
+ my $notesEtime = $arrays->{notesAetime};
+ my $notesTime = $arrays->{notesAtime};
+ my $notesNentries = $arrays->{notesAnentries};
+ my $base_val = $arrays->{baseval};
+ my $base_conn = $arrays->{baseconn};
+ my $base_op = $arrays->{baseop};
+ my $scope_val = $arrays->{scopeval};
+ my $scope_conn = $arrays->{scopeconn};
+ my $scope_op = $arrays->{scopeop};
+ my $filter_val = $arrays->{filterval};
+ my $filter_conn = $arrays->{filterconn};
+ my $filter_op = $arrays->{filterop};
+
+ my $notesCount = "1";
+ my $unindexedIp;
+ for (my $n = 0; $n <= scalar(@{$notesEtime}); $n++){
+ if($conn_hash->{$notesConn->[$n]} eq ""){
$unindexedIp = "?";
} else {
- $unindexedIp = $conn_hash{$notesConn[$n]};
+ $unindexedIp = $conn_hash->{$notesConn->[$n]};
}
print "\n Unindexed Search #".$notesCount."\n"; $notesCount++;
- print " - Date/Time: $notesTime[$n]\n";
- print " - Connection Number: $notesConn[$n]\n";
- print " - Operation Number: $notesOp[$n]\n";
- print " - Etime: $notesEtime[$n]\n";
- print " - Nentries: $notesNentries[$n]\n";
+ print " - Date/Time: $notesTime->[$n]\n";
+ print " - Connection Number: $notesConn->[$n]\n";
+ print " - Operation Number: $notesOp->[$n]\n";
+ print " - Etime: $notesEtime->[$n]\n";
+ print " - Nentries: $notesNentries->[$n]\n";
print " - IP Address: $unindexedIp\n";
- for ($nnn = 0; $nnn < $baseCount; $nnn++){
- if ($notesConn[$n] eq $base_conn[$nnn] && $notesOp[$n] eq $base_op[$nnn]){
- print " - Search Base: $base_val[$nnn]\n";
+ for (my $nnn = 0; $nnn < $baseCount; $nnn++){
+ if ($notesConn->[$n] eq $base_conn->[$nnn] && $notesOp->[$n] eq
$base_op->[$nnn]){
+ print " - Search Base: $base_val->[$nnn]\n";
last;
}
}
- for ($nnn = 0; $nnn < $scopeCount; $nnn++){
- if ($notesConn[$n] eq $scope_conn[$nnn] && $notesOp[$n] eq $scope_op[$nnn]){
- print " - Search Scope: $scope_val[$nnn]\n";
+ for (my $nnn = 0; $nnn < $scopeCount; $nnn++){
+ if ($notesConn->[$n] eq $scope_conn->[$nnn] && $notesOp->[$n] eq
$scope_op->[$nnn]){
+ print " - Search Scope: $scope_val->[$nnn]\n";
last;
}
}
- for ($nnn = 0; $nnn < $filterCount; $nnn++){
- if ($notesConn[$n] eq $filter_conn[$nnn] && $notesOp[$n] eq
$filter_op[$nnn]){
- print " - Search Filter: $filter_val[$nnn]\n";
+ for (my $nnn = 0; $nnn < $filterCount; $nnn++){
+ if ($notesConn->[$n] eq $filter_conn->[$nnn] && $notesOp->[$n] eq
$filter_op->[$nnn]){
+ print " - Search Filter: $filter_val->[$nnn]\n";
last;
}
}
}
- undef %conn_hash;
- undef @notesConn;
- undef @notesOp;
- undef @notesEtime;
- undef @notesTime;
- undef @notesNentries;
- undef @notesIp;
- undef @filter_val;
- undef @filter_conn;
- undef @filter_op;
- undef @base_val;
- undef @base_conn;
- undef @base_op;
- undef @scope_val;
- undef @scope_conn;
- undef @scope_op;
}
if ($unindexedSrchCountNotesU > 0){
- %conn_hash = getHashFromFile($CONN_HASH);
- @notesConn = getArrayFromFile($NOTES_U_CONN);
- @notesOp = getArrayFromFile($NOTES_U_OP);
- @notesEtime = getArrayFromFile($NOTES_U_ETIME);
- @notesTime = getArrayFromFile($NOTES_U_TIME);
- @notesNentries = getArrayFromFile($NOTES_U_NENTRIES);
- getInfoArraysFromFile($BASEINFO);
- @base_val = @fileArray1;
- @base_conn = @fileArray2;
- @base_op = @fileArray3;
- getInfoArraysFromFile($SCOPEINFO);
- @scope_val = @fileArray1;
- @scope_conn = @fileArray2;
- @scope_op = @fileArray3;
- getInfoArraysFromFile($FILTERINFO);
- @filter_val = @fileArray1;
- @filter_conn = @fileArray2;
- @filter_op = @fileArray3;
-
- $notesCount = "1";
- for ($n = 0; $n <= $#notesEtime; $n++){
- @alreadyseenDN = ();
- if($conn_hash{$notesConn[$n]} eq ""){
+ my $conn_hash = $hashes->{conn_hash};
+ my $notesConn = $arrays->{notesUconn};
+ my $notesOp = $arrays->{notesUop};
+ my $notesEtime = $arrays->{notesUetime};
+ my $notesTime = $arrays->{notesUtime};
+ my $notesNentries = $arrays->{notesUnentries};
+ my $base_val = $arrays->{baseval};
+ my $base_conn = $arrays->{baseconn};
+ my $base_op = $arrays->{baseop};
+ my $scope_val = $arrays->{scopeval};
+ my $scope_conn = $arrays->{scopeconn};
+ my $scope_op = $arrays->{scopeop};
+ my $filter_val = $arrays->{filterval};
+ my $filter_conn = $arrays->{filterconn};
+ my $filter_op = $arrays->{filterop};
+
+ my $notesCount = "1";
+ my $unindexedIp;
+ for (my $n = 0; $n <= scalar(@{$notesEtime}); $n++){
+ if($conn_hash->{$notesConn->[$n]} eq ""){
$unindexedIp = "?";
} else {
- $unindexedIp = $conn_hash{$notesConn[$n]};
+ $unindexedIp = $conn_hash->{$notesConn->[$n]};
}
print "\n Unindexed Components #".$notesCount."\n";
$notesCount++;
- print " - Date/Time: $notesTime[$n]\n";
- print " - Connection Number: $notesConn[$n]\n";
- print " - Operation Number: $notesOp[$n]\n";
- print " - Etime: $notesEtime[$n]\n";
- print " - Nentries: $notesNentries[$n]\n";
+ print " - Date/Time: $notesTime->[$n]\n";
+ print " - Connection Number: $notesConn->[$n]\n";
+ print " - Operation Number: $notesOp->[$n]\n";
+ print " - Etime: $notesEtime->[$n]\n";
+ print " - Nentries: $notesNentries->[$n]\n";
print " - IP Address: $unindexedIp\n";
- for ($nnn = 0; $nnn < $baseCount; $nnn++){
- if ($notesConn[$n] eq $base_conn[$nnn] && $notesOp[$n] eq $base_op[$nnn]){
- print " - Search Base: $base_val[$nnn]\n";
+ for (my $nnn = 0; $nnn < $baseCount; $nnn++){
+ if ($notesConn->[$n] eq $base_conn->[$nnn] && $notesOp->[$n] eq
$base_op->[$nnn]){
+ print " - Search Base: $base_val->[$nnn]\n";
last;
}
}
- for ($nnn = 0; $nnn < $scopeCount; $nnn++){
- if ($notesConn[$n] eq $scope_conn[$nnn] && $notesOp[$n] eq $scope_op[$nnn]){
- print " - Search Scope: $scope_val[$nnn]\n";
+ for (my $nnn = 0; $nnn < $scopeCount; $nnn++){
+ if ($notesConn->[$n] eq $scope_conn->[$nnn] && $notesOp->[$n] eq
$scope_op->[$nnn]){
+ print " - Search Scope: $scope_val->[$nnn]\n";
last;
}
}
- for ($nnn = 0; $nnn < $filterCount; $nnn++){
- if ($notesConn[$n] eq $filter_conn[$nnn] && $notesOp[$n] eq
$filter_op[$nnn]){
- print " - Search Filter: $filter_val[$nnn]\n";
+ for (my $nnn = 0; $nnn < $filterCount; $nnn++){
+ if ($notesConn->[$n] eq $filter_conn->[$nnn] && $notesOp->[$n] eq
$filter_op->[$nnn]){
+ print " - Search Filter: $filter_val->[$nnn]\n";
last;
}
}
}
- undef %conn_hash;
- undef @notesConn;
- undef @notesOp;
- undef @notesEtime;
- undef @notesTime;
- undef @notesNentries;
- undef @notesIp;
- undef @filter_val;
- undef @filter_conn;
- undef @filter_op;
- undef @base_val;
- undef @base_conn;
- undef @base_op;
- undef @scope_val;
- undef @scope_conn;
- undef @scope_op;
}
} # end of unindexed search report
@@ -809,10 +768,12 @@ print "FDs Returned: $fdReturned\n";
print "Highest FD Taken: $highestFdTaken\n\n";
print "Broken Pipes: $brokenPipeCount\n";
if ($brokenPipeCount > 0){
- foreach $key (sort { $rc{$b} <=> $rc{$a} } keys %rc) {
- if ($rc{$key} > 0){
+ my $rc = $hashes->{rc};
+ my @etext;
+ foreach my $key (sort { $rc->{$b} <=> $rc->{$a} } keys %{$rc}) {
+ if ($rc->{$key} > 0){
if ($conn{$key} eq ""){$conn{$key} = "**Unknown**";}
- push @etext, sprintf " - %-4s (%2s)
%-40s\n",$rc{$key},$conn{$key},$connmsg{$key
+ push @etext, sprintf " - %-4s (%2s)
%-40s\n",$rc->{$key},$conn{$key},$connmsg{$key
};
}
}
@@ -822,10 +783,12 @@ if ($brokenPipeCount > 0){
print "Connections Reset By Peer: $connResetByPeerCount\n";
if ($connResetByPeerCount > 0){
- foreach $key (sort { $src{$b} <=> $src{$a} } keys %src) {
- if ($src{$key} > 0){
+ my $src = $hashes->{src};
+ my @retext;
+ foreach my $key (sort { $src->{$b} <=> $src->{$a} } keys %{$src}) {
+ if ($src->{$key} > 0){
if ($conn{$key} eq ""){$conn{$key} = "**Unknown**";}
- push @retext, sprintf " - %-4s (%2s)
%-40s\n",$src{$key},$conn{$key},$connmsg{$key
+ push @retext, sprintf " - %-4s (%2s)
%-40s\n",$src->{$key},$conn{$key},$connmsg{$key
};
}
}
@@ -835,10 +798,12 @@ if ($connResetByPeerCount > 0){
print "Resource Unavailable: $resourceUnavailCount\n";
if ($resourceUnavailCount > 0){
- foreach $key (sort { $rsrc{$b} <=> $rsrc{$a} } keys %rsrc) {
- if ($rsrc{$key} > 0){
+ my $rsrc = $hashes->{rsrc};
+ my @rtext;
+ foreach my $key (sort { $rsrc->{$b} <=> $rsrc->{$a} } keys %{$rsrc}) {
+ if ($rsrc->{$key} > 0){
if ($conn{$key} eq ""){$conn{$key} = "**Resource
Issue**";}
- push @rtext, sprintf " - %-4s (%2s)
%-40s\n",$rsrc{$key},$conn{$key},$connmsg{$key};
+ push @rtext, sprintf " - %-4s (%2s)
%-40s\n",$rsrc->{$key},$conn{$key},$connmsg{$key};
}
}
print @rtext;
@@ -854,14 +819,15 @@ print " - SSL Client Binds:
$sslClientBindCount\n";
print " - Failed SSL Client Binds: $sslClientFailedCount\n";
print " - SASL Binds: $saslBindCount\n";
if ($saslBindCount > 0){
- foreach $saslb ( sort {$saslmech{$b} <=> $saslmech{$a} } (keys %saslmech) ){
- printf " %-4s %-12s\n",$saslmech{$saslb}, $saslb;
- }
+ my $saslmech = $hashes->{saslmech};
+ foreach my $saslb ( sort {$saslmech->{$b} <=> $saslmech->{$a} } (keys
%{$saslmech}) ){
+ printf " %-4s %-12s\n",$saslmech->{$saslb}, $saslb;
+ }
}
print " - Directory Manager Binds: $rootDNBindCount\n";
print " - Anonymous Binds: $anonymousBindCount\n";
-$otherBindCount = $bindCount -($rootDNBindCount + $anonymousBindCount);
+my $otherBindCount = $bindCount -($rootDNBindCount + $anonymousBindCount);
print " - Other Binds: $otherBindCount\n\n";
##########################################################################
@@ -879,8 +845,10 @@ if ($verb eq "yes" || $usage =~ /y/){
print " (in seconds)\t\t<=1\t2\t3\t4-5\t6-10\t11-15\t>15\n";
print "
--------------------------------------------------------------------------\n";
print " (# of connections)\t";
- for ($i=0; $i <=$#latency; $i++) {
- print "$latency[$i]\t";
+ for (my $i=0; $i <=$#latency; $i++) {
+ if (defined($latency[$i])) {
+ print "$latency[$i]\t";
+ }
}
}
@@ -891,9 +859,9 @@ if ($verb eq "yes" || $usage =~ /y/){
###################################
if ($verb eq "yes" || $usage =~ /p/){
- if ($openConnection[0] ne ""){
+ if (@openConnection > 0){
print "\n\n----- Current Open Connection IDs ----- \n\n";
- for ($i=0; $i <= $#openConnection ; $i++) {
+ for (my $i=0; $i <= $#openConnection ; $i++) {
if ($openConnection[$i]) {
print "Conn Number: $i (" . getIPfromConn($i) . ")\n";
}
@@ -910,17 +878,16 @@ if ($verb eq "yes" || $usage =~ /p/){
if ($usage =~ /e/i || $verb eq "yes"){
print "\n\n----- Errors -----\n";
- %er = sort( {$b <=> $a} %er);
- for ($i = 0; $i<98; $i++){
- if ($err[$i] ne "" && $errorCode[$i] >0) {
+ for (my $i = 0; $i<98; $i++){
+ if (defined($err[$i]) && $err[$i] ne "" &&
defined($errorCode[$i]) && $errorCode[$i] >0) {
push @errtext, sprintf "%-8s %12s
%-25s","err=$i",$errorCode[$i],$err[$i];
}
}
- for ($i = 0; $i < $#errtext; $i++){
- for ($ii = 0; $ii < $#errtext; $ii++){
- $yy="0";
- $zz="0";
+ for (my $i = 0; $i < $#errtext; $i++){
+ for (my $ii = 0; $ii < $#errtext; $ii++){
+ my $yy="0";
+ my $zz="0";
while ($errtext[$ii] =~ /(\w+)\s/g){
$errornum[$yy]="$1";
$yy++;
@@ -936,7 +903,7 @@ if ($usage =~ /e/i || $verb eq "yes"){
}
}
}
- for ($i = 0; $i <= $#errtext; $i++){
+ for (my $i = 0; $i <= $#errtext; $i++){
$errtext[$i] =~ s/\n//g;
print "\n" . $errtext[$i];
}
@@ -953,51 +920,44 @@ if ($verb eq "yes" || $usage =~ /f/ ){
print "\n\n----- Top $sizeCount Failed Logins ------\n\n";
if ($ds6x eq "true"){
- %ds6xbadpwd = getCounterHashFromFile($DS6XBADPWD);
- $ds6loop = 0;
- foreach $ds6bp (sort { $ds6xbadpwd{$b} <=> $ds6xbadpwd{$a} } keys %ds6xbadpwd)
{
- if ($eloop > $sizeCount){ last; }
- printf "%-4s %-40s\n", $ds6xbadpwd{$ds6bp}, $ds6bp;
+ my $ds6xbadpwd = $hashes->{ds6xbadpwd};
+ my $ds6loop = 0;
+ foreach my $ds6bp (sort { $ds6xbadpwd->{$b} <=> $ds6xbadpwd->{$a} } keys
%{$ds6xbadpwd}) {
+ if ($ds6loop > $sizeCount){ last; }
+ printf "%-4s %-40s\n", $ds6xbadpwd->{$ds6bp}, $ds6bp;
$ds6loop++;
}
- undef %ds6xbadpwd;
} else {
- getInfoArraysFromFile($BINDINFO);
- @bindVal = @fileArray1;
- @bindConn = @fileArray2;
- @bindOp = @fileArray3;
- @badPasswordConn = getArrayFromFile($BADPWDCONN);
- @badPasswordOp = getArrayFromFile($BADPWDOP);
- @badPasswordIp = getArrayFromFile($BADPWDIP);
- for ($ii =0 ; $ii < $badPwdCount; $ii++){
- for ($i = 0; $i < $bindCount; $i++){
- if ($badPasswordConn[$ii] eq $bindConn[$i] && $badPasswordOp[$ii] eq
$bindOp[$i] ){
- $badPassword{ "$bindVal[$i]" } = $badPassword{ "$bindVal[$i]" }
+ 1;
+ my $bindVal = $arrays->{binddn};
+ my $bindConn = $arrays->{bindconn};
+ my $bindOp = $arrays->{bindop};
+ my $badPasswordConn = $arrays->{badpwdconn};
+ my $badPasswordOp = $arrays->{badpwdop};
+ my $badPasswordIp = $arrays->{badpwdip};
+ my %badPassword = ();
+ for (my $ii =0 ; $ii < $badPwdCount; $ii++){
+ for (my $i = 0; $i < $bindCount; $i++){
+ if ($badPasswordConn->[$ii] eq $bindConn->[$i] &&
$badPasswordOp->[$ii] eq $bindOp->[$i] ){
+ $badPassword{ $bindVal->[$i] }++;
}
}
}
# sort the new hash of $badPassword{}
- $bpTotal = 0;
- $bpCount = 0;
- foreach $badpw (sort {$badPassword{$b} <=> $badPassword{$a} } keys
%badPassword){
+ my $bpTotal = 0;
+ my $bpCount = 0;
+ foreach my $badpw (sort {$badPassword{$b} <=> $badPassword{$a} } keys
%badPassword){
if ($bpCount > $sizeCount){ last;}
$bpCount++;
$bpTotal = $bpTotal + $badPassword{"$badpw"};
printf "%-4s %-40s\n", $badPassword{"$badpw"}, $badpw;
}
print "\nFrom the IP address(s) :\n\n";
- for ($i=0; $i<$badPwdCount; $i++) {
- print "\t\t$badPasswordIp[$i]\n";
+ for (my $i=0; $i<$badPwdCount; $i++) {
+ print "\t\t$badPasswordIp->[$i]\n";
}
if ($bpTotal > $badPwdCount){
print "\n** Warning : Wrongly reported failed login attempts : ". ($bpTotal
- $badPwdCount) . "\n";
}
- undef @bindVal;
- undef @bindConn;
- undef @bindOp;
- undef @badPasswordConn;
- undef @badPasswordOp;
- undef @badPasswordIp;
} # this ends the if $ds6x = true
}
}
@@ -1012,15 +972,14 @@ if ($verb eq "yes" || $usage =~ /f/ ){
if ($connCodeCount > 0){
if ($usage =~ /c/i || $verb eq "yes"){
print "\n\n----- Total Connection Codes -----\n\n";
- %conncount = &getCounterHashFromFile($CONNCOUNT);
-
- foreach $key (sort { $conncount{$b} <=> $conncount{$a} } keys %conncount) {
- if ($conncount{$key} > 0){
- push @conntext, sprintf "%-4s %6s
%-40s\n",$key,$conncount{$key},$connmsg{ $key };
+ my $conncount = $hashes->{conncount};
+ my @conntext;
+ foreach my $key (sort { $conncount->{$b} <=> $conncount->{$a} } keys
%{$conncount}) {
+ if ($conncount->{$key} > 0){
+ push @conntext, sprintf "%-4s %6s
%-40s\n",$key,$conncount->{$key},$connmsg{ $key };
}
}
print @conntext;
- undef %conncount;
}
}
@@ -1031,35 +990,36 @@ if ($connCodeCount > 0){
########################################
if ($usage =~ /i/i || $verb eq "yes"){
- %ip_hash = getTwoDimHashFromFile($IP_HASH);
- %exCount = getCounterHashFromFile($EXCOUNT);
- @ipkeys = keys %ip_hash;
- @exxCount = keys %exCount;
- $ip_count = ($#ipkeys + 1)-($#exxCount + 1);
+ my $ip_hash = $hashes->{ip_hash};
+ my $exCount = $hashes->{excount};
+ my @ipkeys = keys %{$ip_hash};
+ my @exxCount = keys %${exCount};
+ my $ip_count = ($#ipkeys + 1)-($#exxCount + 1);
+ my $ccount = 0;
if ($ip_count > 0){
print "\n\n----- Top $sizeCount Clients -----\n\n";
print "Number of Clients: $ip_count\n\n";
- foreach $key (sort { $ip_hash{$b}{"count"} <=>
$ip_hash{$a}{"count"} } keys %ip_hash) {
- $exc = "no";
+ foreach my $key (sort { $ip_hash->{$b} <=> $ip_hash->{$a} } @ipkeys) {
+ my $exc = "no";
if ($ccount > $sizeCount){ last;}
$ccount++;
- for ($xxx =0; $xxx <= $#excludeIP; $xxx++){
+ for (my $xxx =0; $xxx < $#excludeIP; $xxx++){
if ($excludeIP[$xxx] eq $key){$exc = "yes";}
}
if ($exc ne "yes"){
- if ($ip_hash{ $key }{"count"} eq ""){$ip_hash{ $key
}{"count"} = "?";}
+ if ($ip_hash->{ $key } eq ""){$ip_hash->{ $key } = "?";}
printf "[%s] Client: %s\n",$ccount, $key;
- printf "%10s - Connections\n", $ip_hash{ $key }{"count"};
- foreach $code (sort { $ip_hash{ $key }{$b} <=> $ip_hash{ $key }{$a} } keys
%{$ip_hash{ $key }}) {
+ printf "%10s - Connections\n", $ip_hash->{ $key };
+ my %counts;
+ map { $counts{$_} = $hashes->{$_}->{$key} if
(defined($hashes->{$_}->{$key})) } @conncodes;
+ foreach my $code (sort { $counts{$b} <=> $counts{$a} } keys %counts) {
if ($code eq 'count' ) { next; }
- printf "%10s - %s (%s)\n", $ip_hash{ $key }{ $code }, $code, $connmsg{
$code };
+ printf "%10s - %s (%s)\n", $counts{ $code }, $code, $connmsg{ $code };
}
print "\n";
}
}
}
- undef %exCount;
- undef %ip_hash;
}
###################################
@@ -1069,21 +1029,22 @@ if ($usage =~ /i/i || $verb eq "yes"){
###################################
if ($usage =~ /b/i || $verb eq "yes"){
- %bindlist = getCounterHashFromFile($BINDLIST);
- @bindkeys = keys %bindlist;
- $bind_count = $#bindkeys + 1;
+ my $bindlist = $hashes->{bindlist};
+ my @bindkeys = keys %{$bindlist};
+ my $bind_count = $#bindkeys + 1;
if ($bind_count > 0){
print "\n\n----- Top $sizeCount Bind DN's -----\n\n";
print "Number of Unique Bind DN's: $bind_count\n\n";
- $bindcount = 0;
- foreach $dn (sort { $bindlist{$b} <=> $bindlist{$a} } keys %bindlist) {
- if ($bindcount < $sizeCount){
- printf "%-8s %-40s\n", $bindlist{ $dn },$dn;
- }
+ my $bindcount = 0;
+ foreach my $dn (sort { $bindlist->{$b} <=> $bindlist->{$a} } @bindkeys) {
+ if ($bindcount < $sizeCount){
+ printf "%-8s %-40s\n", $bindlist->{ $dn },$dn;
+ } else {
+ last;
+ }
$bindcount++;
}
}
- undef %bindlist;
}
#########################################
@@ -1093,21 +1054,22 @@ if ($usage =~ /b/i || $verb eq "yes"){
#########################################
if ($usage =~ /a/i || $verb eq "yes"){
- %base = getCounterHashFromFile($BASE);
- @basekeys = keys %base;
- $base_count = $#basekeys + 1;
+ my $base = $hashes->{base};
+ my @basekeys = keys %{$base};
+ my $base_count = $#basekeys + 1;
if ($base_count > 0){
print "\n\n----- Top $sizeCount Search Bases -----\n\n";
print "Number of Unique Search Bases: $base_count\n\n";
- $basecount = 0;
- foreach $bas (sort { $base{$b} <=> $base{$a} } keys %base) {
+ my $basecount = 0;
+ foreach my $bas (sort { $base->{$b} <=> $base->{$a} } @basekeys) {
if ($basecount < $sizeCount){
- printf "%-8s %-40s\n", $base{ $bas },$bas;
- }
+ printf "%-8s %-40s\n", $base->{ $bas },$bas;
+ } else {
+ last;
+ }
$basecount++;
}
}
- undef %base;
}
#########################################
@@ -1117,21 +1079,22 @@ if ($usage =~ /a/i || $verb eq "yes"){
#########################################
if ($usage =~ /l/ || $verb eq "yes"){
- %filter = getCounterHashFromFile($FILTER);
- @filterkeys = keys %filter;
- $filter_count = $#filterkeys + 1;
+ my $filter = $hashes->{filter};
+ my @filterkeys = keys %{$filter};
+ my $filter_count = $#filterkeys + 1;
if ($filter_count > 0){
print "\n\n----- Top $sizeCount Search Filters -----\n";
print "\nNumber of Unique Search Filters: $filter_count\n\n";
- $filtercount = 0;
- foreach $filt (sort { $filter{$b} <=> $filter{$a} } keys %filter){
+ my $filtercount = 0;
+ foreach my $filt (sort { $filter->{$b} <=> $filter->{$a} } @filterkeys){
if ($filtercount < $sizeCount){
- printf "%-8s %-40s\n", $filter{$filt}, $filt;
- }
+ printf "%-8s %-40s\n", $filter->{$filt}, $filt;
+ } else {
+ last;
+ }
$filtercount++;
}
}
- undef %filter;
}
#########################################
@@ -1140,20 +1103,23 @@ if ($usage =~ /l/ || $verb eq "yes"){
# #
#########################################
+my $first;
if ($usage =~ /t/i || $verb eq "yes"){
- %etime = getCounterHashFromFile($ETIME);
+ my $etime = $hashes->{etime};
+ my @ekeys = keys %{$etime};
#
# print most often etimes
#
print "\n\n----- Top $sizeCount Most Frequent etimes -----\n\n";
- $eloop = 0;
- foreach $et (sort { $etime{$b} <=> $etime{$a} } keys %etime) {
+ my $eloop = 0;
+ my $retime = 0;
+ foreach my $et (sort { $etime->{$b} <=> $etime->{$a} } @ekeys) {
if ($eloop == $sizeCount) { last; }
if ($retime ne "2"){
$first = $et;
$retime = "2";
}
- printf "%-8s %-12s\n", $etime{ $et }, "etime=$et";
+ printf "%-8s %-12s\n", $etime->{ $et }, "etime=$et";
$eloop++;
}
#
@@ -1161,12 +1127,11 @@ if ($usage =~ /t/i || $verb eq "yes"){
#
print "\n\n----- Top $sizeCount Longest etimes -----\n\n";
$eloop = 0;
- foreach $et (sort { $b <=> $a } (keys %etime)) {
+ foreach my $et (sort { $b <=> $a } @ekeys) {
if ($eloop == $sizeCount) { last; }
- printf "%-12s %-10s\n","etime=$et",$etime{ $et };
+ printf "%-12s %-10s\n","etime=$et",$etime->{ $et };
$eloop++;
}
- undef %etime;
}
#######################################
@@ -1177,23 +1142,23 @@ if ($usage =~ /t/i || $verb eq "yes"){
if ($usage =~ /n/i || $verb eq "yes"){
- %nentries = getCounterHashFromFile($NENTRIES);
+ my $nentries = $hashes->{nentries};
+ my @nkeys = keys %{$nentries};
print "\n\n----- Top $sizeCount Largest nentries -----\n\n";
- $eloop = 0;
- foreach $nentry (sort { $b <=> $a } (keys %nentries)){
+ my $eloop = 0;
+ foreach my $nentry (sort { $b <=> $a } @nkeys){
if ($eloop == $sizeCount) { last; }
- printf "%-18s %12s\n","nentries=$nentry", $nentries{ $nentry
};
+ printf "%-18s %12s\n","nentries=$nentry", $nentries->{
$nentry };
$eloop++;
}
print "\n\n----- Top $sizeCount Most returned nentries -----\n\n";
$eloop = 0;
- foreach $nentry (sort { $nentries{$b} <=> $nentries{$a} } (keys %nentries)){
+ foreach my $nentry (sort { $nentries->{$b} <=> $nentries->{$a} } @nkeys){
if ($eloop == $sizeCount) { last; }
- printf "%-12s %-14s\n", $nentries{ $nentry },
"nentries=$nentry";
+ printf "%-12s %-14s\n", $nentries->{ $nentry },
"nentries=$nentry";
$eloop++;
}
print "\n";
- undef %nentries;
}
##########################################
@@ -1204,9 +1169,10 @@ if ($usage =~ /n/i || $verb eq "yes"){
if ($usage =~ /x/i || $verb eq "yes"){
if ($extopCount > 0){
- %oid = getCounterHashFromFile($OID);
+ my $oid = $hashes->{oid};
print "\n\n----- Extended Operations -----\n\n";
- foreach $oids (sort { $oid{$b} <=> $oid{$a} } (keys %oid) ){
+ foreach my $oids (sort { $oid->{$b} <=> $oid->{$a} } (keys %{$oid}) ){
+ my $oidmessage;
if ($oids eq "2.16.840.1.113730.3.5.1"){ $oidmessage = "Transaction
Request"} #depreciated?
elsif ($oids eq "2.16.840.1.113730.3.5.2"){ $oidmessage = "Transaction
Response"} #depreciated?
elsif ($oids eq "2.16.840.1.113730.3.5.3"){ $oidmessage = "Start
Replication Request (incremental update)"}
@@ -1236,9 +1202,8 @@ if ($usage =~ /x/i || $verb eq "yes"){
elsif ($oids eq "1.3.6.1.4.1.4203.1.11.1"){ $oidmessage = "Password
Modify"}
elsif ($oids eq "2.16.840.1.113730.3.4.20"){ $oidmessage = "MTN Control
Use One Backend"}
else {$oidmessage = "Other"}
- printf "%-6s %-23s %-60s\n", $oid{ $oids }, $oids, $oidmessage;
+ printf "%-6s %-23s %-60s\n", $oid->{ $oids }, $oids,
$oidmessage;
}
- undef %oid;
}
}
@@ -1250,15 +1215,14 @@ if ($usage =~ /x/i || $verb eq "yes"){
if ($usage =~ /r/i || $verb eq "yes"){
if ($anyAttrs > 0){
- %attr = getCounterHashFromFile($ATTR);
+ my $attr = $hashes->{attr};
print "\n\n----- Top $sizeCount Most Requested Attributes -----\n\n";
- $eloop = 0;
- foreach $mostAttr (sort { $attr{$b} <=> $attr{$a} } (keys %attr) ){
+ my $eloop = 0;
+ foreach my $mostAttr (sort { $attr->{$b} <=> $attr->{$a} } (keys %{$attr})
){
if ($eloop eq $sizeCount){ last; }
- printf "%-10s %-19s\n", $attr{$mostAttr}, $mostAttr;
+ printf "%-10s %-19s\n", $attr->{$mostAttr}, $mostAttr;
$eloop++;
}
- undef %attr;
}
}
@@ -1269,77 +1233,59 @@ if ($usage =~ /r/i || $verb eq "yes"){
#############################
if ($usage =~ /g/i || $verb eq "yes"){
- $abandonTotal = $srchCount + $delCount + $modCount + $addCount + $modrdnCount +
$bindCount + $extopCount + $cmpCount;
+ my $abandonTotal = $srchCount + $delCount + $modCount + $addCount + $modrdnCount +
$bindCount + $extopCount + $cmpCount;
if ($verb eq "yes" && $abandonCount > 0 && $abandonTotal
> 0){
- %conn_hash = getHashFromFile($CONN_HASH);
- @srchConn = getArrayFromFile($SRCH_CONN);
- @srchOp = getArrayFromFile($SRCH_OP);
- @delConn = getArrayFromFile($DEL_CONN);
- @delOp = getArrayFromFile($DEL_OP);
- @targetConn = getArrayFromFile($TARGET_CONN);
- @targetOp = getArrayFromFile($TARGET_OP);
- @msgid = getArrayFromFile($MSGID);
- @addConn = getArrayFromFile($ADD_CONN);
- @addOp = getArrayFromFile($ADD_OP);
- @modConn = getArrayFromFile($MOD_CONN);
- @modOp = getArrayFromFile($MOD_OP);
- @cmpConn = getArrayFromFile($CMP_CONN);
- @cmpOp = getArrayFromFile($CMP_OP);
- @modrdnConn = getArrayFromFile($MODRDN_CONN);
- @modrdnOp = getArrayFromFile($MODRDN_OP);
- @bindConn = getArrayFromFile($BIND_CONN);
- @bindOp = getArrayFromFile($BIND_OP);
- @unbindConn = getArrayFromFile($UNBIND_CONN);
- @unbindOp = getArrayFromFile($UNBIND_OP);
- @extConn = getArrayFromFile($EXT_CONN);
- @extOp = getArrayFromFile($EXT_OP);
+ my $conn_hash = $hashes->{conn_hash};
print "\n\n----- Abandon Request Stats -----\n\n";
- for ($g = 0; $g < $abandonCount; $g++){
- for ($sc = 0; $sc < $srchCount; $sc++){
- if ($srchConn[$sc] eq $targetConn[$g] && $srchOp[$sc] eq $targetOp[$g] ){
- print " - SRCH conn=$targetConn[$g] op=$targetOp[$g] msgid=$msgid[$g]
client=$conn_hash{$targetConn[$g]}\n";
+ for (my $g = 0; $g < $abandonCount; $g++){
+ my $conn = $arrays->{targetconn}->[$g];
+ my $op = $arrays->{targetop}->[$g];
+ my $msgid = $arrays->{msgid}->[$g];
+ for (my $sc = 0; $sc < $srchCount; $sc++){
+ if ($arrays->{srchconn}->[$sc] eq $conn &&
$arrays->{srchop}->[$sc] eq $op ){
+ print " - SRCH conn=$conn op=$op msgid=$msgid
client=$conn_hash->{$conn}\n";
}
}
- for ($dc = 0; $dc < $delCount; $dc++){
- if ($delConn[$dc] eq $targetConn[$g] && $delOp[$dc] eq $targetOp[$g]){
- print " - DEL conn=$targetConn[$g] op=$targetOp[$g] msgid=$msgid[$g]
client=$conn_hash{$targetConn[$g]}\n";
+ for (my $dc = 0; $dc < $delCount; $dc++){
+ if ($arrays->{delconn}->[$dc] eq $conn && $arrays->{delop}->[$dc]
eq $op){
+ print " - DEL conn=$conn op=$op msgid=$msgid
client=$conn_hash->{$conn}\n";
}
}
- for ($adc = 0; $adc < $addCount; $adc++){
- if ($addConn[$adc] eq $targetConn[$g] && $addOp[$adc] eq $targetOp[$g]){
- print " - ADD conn=$targetConn[$g] op=$targetOp[$g] msgid=$msgid[$g]
client=$conn_hash{$targetConn[$g]}\n";
+ for (my $adc = 0; $adc < $addCount; $adc++){
+ if ($arrays->{addconn}->[$adc] eq $conn &&
$arrays->{addop}->[$adc] eq $op){
+ print " - ADD conn=$conn op=$op msgid=$msgid
client=$conn_hash->{$conn}\n";
}
}
- for ($mc = 0; $mc < $modCount; $mc++){
- if ($modConn[$mc] eq $targetConn[$g] && $modOp[$mc] eq $targetOp[$g]){
- print " - MOD conn=$targetConn[$g] op=$targetOp[$g] msgid=$msgid[$g]
client=$conn_hash{$targetConn[$g]}\n";
+ for (my $mc = 0; $mc < $modCount; $mc++){
+ if ($arrays->{modconn}->[$mc] eq $conn && $arrays->{modop}->[$mc]
eq $op){
+ print " - MOD conn=$conn op=$op msgid=$msgid
client=$conn_hash->{$conn}\n";
}
}
- for ($cc = 0; $cc < $cmpCount; $cc++){
- if ($cmpConn[$mdc] eq $targetConn[$g] && $cmpOp[$mdc] eq $targetOp[$g]){
- print " - CMP conn=$targetConn[$g] op=$targetOp[$g] msgid=$msgid[$g]
client=$conn_hash{$targetConn[$g]}\n";
+ for (my $cc = 0; $cc < $cmpCount; $cc++){
+ if ($arrays->{cmpconn}->[$cc] eq $conn && $arrays->{cmpop}->[$cc]
eq $op){
+ print " - CMP conn=$conn op=$op msgid=$msgid
client=$conn_hash->{$conn}\n";
}
}
- for ($mdc = 0; $mdc < $modrdnCount; $mdc++){
- if ($modrdnConn[$mdc] eq $targetConn[$g] && $modrdnOp[$mdc] eq
$targetOp[$g]){
- print " - MODRDN conn=$targetConn[$g] op=$targetOp[$g] msgid=$msgid[$g]
client=$conn_hash{$targetConn[$g]}\n";
+ for (my $mdc = 0; $mdc < $modrdnCount; $mdc++){
+ if ($arrays->{modrdnconn}->[$mdc] eq $conn &&
$arrays->{modrdnop}->[$mdc] eq $op){
+ print " - MODRDN conn=$conn op=$op msgid=$msgid
client=$conn_hash->{$conn}\n";
}
}
- for ($bcb = 0; $bcb < $bindCount; $bcb++){
- if ($bindConn[$bcb] eq $targetConn[$g] && $bindOp[$bcb] eq $targetOp[$g]){
- print " - BIND conn=$targetConn[$g] op=$targetOp[$g] msgid=$msgid[$g]
client=$conn_hash{$targetConn[$g]}\n";
+ for (my $bcb = 0; $bcb < $bindCount; $bcb++){
+ if ($arrays->{bindconn}->[$bcb] eq $conn &&
$arrays->{bindop}->[$bcb] eq $op){
+ print " - BIND conn=$conn op=$op msgid=$msgid
client=$conn_hash->{$conn}\n";
}
}
- for ($ubc = 0; $ubc < $unbindCount; $ubc++){
- if ($unbindConn[$ubc] eq $targetConn[$g] && $unbindOp[$ubc] eq
$targetOp[$g]){
- print " - UNBIND conn=$targetConn[$g] op=$targetOp[$g] msgid=$msgid[$g]
client=$conn_hash{$targetConn[$g]}\n";
+ for (my $ubc = 0; $ubc < $unbindCount; $ubc++){
+ if ($arrays->{unbindconn}->[$ubc] eq $conn &&
$arrays->{unbindop}->[$ubc] eq $op){
+ print " - UNBIND conn=$conn op=$op msgid=$msgid
client=$conn_hash->{$conn}\n";
}
}
- for ($ec = 0; $ec < $extopCount; $ec++){
- if ($extConn[$ec] eq $targetConn[$g] && $extOp[$ec] eq $targetOp[$g]){
- print " - EXT conn=$targetConn[$g] op=$targetOp[$g] msgid=$msgid[$g]
client=$conn_hash{$targetConn[$g]}\n";
+ for (my $ec = 0; $ec < $extopCount; $ec++){
+ if ($arrays->{extconn}->[$ec] eq $conn && $arrays->{extop}->[$ec]
eq $op){
+ print " - EXT conn=$conn op=$op msgid=$msgid
client=$conn_hash->{$conn}\n";
}
}
}
@@ -1354,9 +1300,9 @@ print "\n";
#######################################
if ($usage =~ /j/i || $verb eq "yes"){
- %conncount = getCounterHashFromFile($CONNCOUNT);
+ my $conncount = $hashes->{conncount};
print "\n----- Recommendations -----\n";
- $recCount = "1";
+ my $recCount = "1";
if ($unindexedSrchCountNotesA > 0){
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";
$recCount++;
@@ -1365,11 +1311,11 @@ if ($usage =~ /j/i || $verb eq "yes"){
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";
$recCount++;
}
- if ($conncount{"T1"} > 0){
+ if (defined($conncount->{"T1"}) and $conncount->{"T1"} >
0){
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";
$recCount++;
}
- if ($conncount{"T2"} > 0){
+ if (defined($conncount->{"T2"}) and $conncount->{"T2"} >
0){
print "\n $recCount. You have some coonections that are being closed by the
ioblocktimeout setting. You may want to increase the ioblocktimeout.\n";
$recCount++;
}
@@ -1391,7 +1337,7 @@ if ($usage =~ /j/i || $verb eq "yes"){
print "\n $recCount. You have more unsuccessful operations than successful
operations. You should investigate this difference.\n";
$recCount++;
}
- if ($conncount{"U1"} < ($connCodeCount - $conncount{"U1"})){
+ if (defined($conncount->{"U1"}) and $conncount->{"U1"} <
($connCodeCount - $conncount->{"U1"})){
print "\n $recCount. You have more abnormal connection codes than cleanly closed
connections. You may want to investigate this difference.\n";
$recCount++;
}
@@ -1407,7 +1353,6 @@ if ($usage =~ /j/i || $verb eq "yes"){
print "\nNone.\n";
}
print "\n";
- undef %conncount;
}
#
@@ -1499,11 +1444,9 @@ parseLineBind {
$linesProcessed++;
$lineBlockCount++;
local $_ = $logline;
+ my $ip;
- if ($lineBlockCount >= $limit){
- print STDERR sprintf" %10s Lines Processed\n",$linesProcessed;
- $lineBlockCount="0";
- }
+ statusreport();
# skip blank lines
return if $_ =~ /^\s/;
@@ -1531,7 +1474,8 @@ parseLineBind {
}
}
if ($_ =~ /connection from *([0-9A-Fa-f\.\:]+)/i ) {
- for ($excl =0; $excl <= $#excludeIP; $excl++){
+ my $skip = "yes";
+ for (my $excl =0; $excl < $#excludeIP; $excl++){
if ($excludeIP[$excl] eq $1){
$skip = "yes";
last;
@@ -1547,6 +1491,7 @@ parseLineBind {
return;
}
if (/ BIND/ && $_ =~ /dn=\"(.*)\" method/i ){
+ my $dn;
if ($1 eq ""){
$dn = "Anonymous";
} else {
@@ -1599,30 +1544,36 @@ parseLineBind {
sub
processOpForBindReport
{
- $op = @_[0];
- $data = @_[1];
+ my $op = shift;
+ my $data = shift;
if ($data =~ /conn= *([0-9]+)/i) {
- foreach $dn (keys %bindReport){
+ foreach my $dn (keys %bindReport){
if ($bindReport{$dn}{"conn"} =~ / $1 /){
- $bindDN = $dn;
- $bindReport{$bindDN}{$op}++;
+ $bindReport{$dn}{$op}++;
return;
}
}
}
}
+my ($last_tm, $lastzone, $last_min, $gmtime, $tzoff);
sub parseLineNormal
{
local $_ = $logline;
+ my $ip;
+ my $tmpp;
+ my $exc = "no";
+ my $connID;
+ my $con;
+ my $op;
+ $linesProcessed++;
+ $lineBlockCount++;
# lines starting blank are restart
return if $_ =~ /^\s/;
- $linesProcessed++;
- $lineBlockCount++;
- if ($lineBlockCount >= $limit){ print STDERR sprintf" %10s Lines
Processed\n",$linesProcessed; $lineBlockCount="0";}
+ statusreport();
# gather/process the timestamp
if($firstFile == 1 && $_ =~ /^\[/){
@@ -1648,30 +1599,30 @@ sub parseLineNormal
}
# Additional performance stats
- ($time, $tzone) = split (' ', $_);
- if ($reportStats && $time ne $last_tm)
+ my ($time, $tzone) = split (' ', $_);
+ if (($reportStats or ($verb eq "yes") || ($usage =~ /y/)) &&
(!defined($last_tm) or ($time ne $last_tm)))
{
$last_tm = $time;
$time =~ s/\[//;
$tzone =~ s/\].*//;
- if($tzone ne $lastzone)
+ if(!defined($lastzone) or $tzone ne $lastzone)
{
# tz offset change
$lastzone=$tzone;
- ($sign,$hr,$min) = $tzone =~ m/(.)(\d\d)(\d\d)/;
+ my ($sign,$hr,$min) = $tzone =~ m/(.)(\d\d)(\d\d)/;
$tzoff = $hr*3600 + $min*60;
$tzoff *= -1
if $sign eq '-';
# to be subtracted from converted values.
}
- ($date, $hr, $min, $sec) = split (':', $time);
- ($day, $mon, $yr) = split ('/', $date);
- $newmin = timegm(0, $min, $hr, $day, $monthname{$mon}, $yr) - $tzoff;
+ my ($date, $hr, $min, $sec) = split (':', $time);
+ my ($day, $mon, $yr) = split ('/', $date);
+ my $newmin = timegm(0, $min, $hr, $day, $monthname{$mon}, $yr) - $tzoff;
$gmtime = $newmin + $sec;
print_stats_block( $s_stats );
reset_stats_block( $s_stats, $gmtime, $time.' '.$tzone );
- if ($newmin != $last_min)
+ if (!defined($last_min) or $newmin != $last_min)
{
print_stats_block( $m_stats );
$time =~ s/\d\d$/00/;
@@ -1689,58 +1640,57 @@ sub parseLineNormal
if($reportStats){ inc_stats('srch',$s_stats,$m_stats); }
if ($_ =~ / attrs=\"(.*)\"/i){
$anyAttrs++;
- $attrs = $1 . " ";
- while ($attrs =~ /(\S+)\s/g){
- writeFile($ATTR, $1);
- }
- }
+ my $attr = $hashes->{attr};
+ map { $attr->{$_}++ } split /\s/, $1;
+ }
if (/ attrs=ALL/){
- writeFile($ATTR, "All Attributes");
+ my $attr = $hashes->{attr};
+ $attr->{"All Attributes"}++;
$anyAttrs++;
}
- if ($verb eq "yes"){
- if ($_ =~ /conn= *([0-9]+)/i){ writeFile($SRCH_CONN, $1);}
- if ($_ =~ /op= *([0-9]+)/i){ writeFile($SRCH_OP, $1);}
+ if ($verb eq "yes"){
+ if ($_ =~ /conn= *([0-9]+)/i){ push @{$arrays->{srchconn}}, $1;}
+ if ($_ =~ /op= *([0-9]+)/i){ push @{$arrays->{srchop}}, $1;}
}
}
if (m/ DEL/){
$delCount++;
if($reportStats){ inc_stats('del',$s_stats,$m_stats); }
if ($verb eq "yes"){
- if ($_ =~ /conn= *([0-9]+)/i){ writeFile($DEL_CONN, $1);}
- if ($_ =~ /op= *([0-9]+)/i){ writeFile($DEL_OP, $1);}
+ if ($_ =~ /conn= *([0-9]+)/i){ push @{$arrays->{delconn}}, $1;}
+ if ($_ =~ /op= *([0-9]+)/i){ push @{$arrays->{delop}}, $1;}
}
}
if (m/ MOD dn=/){
$modCount++;
if($reportStats){ inc_stats('mod',$s_stats,$m_stats); }
if ($verb eq "yes"){
- if ($_ =~ /conn= *([0-9]+)/i){ writeFile($MOD_CONN, $1);}
- if ($_ =~ /op= *([0-9]+)/i){ writeFile($MOD_OP, $1); }
+ if ($_ =~ /conn= *([0-9]+)/i){ push @{$arrays->{modconn}}, $1;}
+ if ($_ =~ /op= *([0-9]+)/i){ push @{$arrays->{modop}}, $1; }
}
}
if (m/ ADD/){
$addCount++;
if($reportStats){ inc_stats('add',$s_stats,$m_stats); }
if ($verb eq "yes"){
- if ($_ =~ /conn= *([0-9]+)/i){ writeFile($ADD_CONN, $1); }
- if ($_ =~ /op= *([0-9]+)/i){ writeFile($ADD_OP, $1); }
+ if ($_ =~ /conn= *([0-9]+)/i){ push @{$arrays->{addconn}}, $1; }
+ if ($_ =~ /op= *([0-9]+)/i){ push @{$arrays->{addop}}, $1; }
}
}
if (m/ MODRDN/){
$modrdnCount++;
if($reportStats){ inc_stats('modrdn',$s_stats,$m_stats); }
if ($verb eq "yes"){
- if ($_ =~ /conn= *([0-9]+)/i){ writeFile($MODRDN_CONN, $1); }
- if ($_ =~ /op= *([0-9]+)/i){ writeFile($MODRDN_OP, $1); }
+ if ($_ =~ /conn= *([0-9]+)/i){ push @{$arrays->{modrdnconn}}, $1; }
+ if ($_ =~ /op= *([0-9]+)/i){ push @{$arrays->{modrdnop}}, $1; }
}
}
if (m/ CMP dn=/){
$cmpCount++;
if($reportStats){ inc_stats('cmp',$s_stats,$m_stats); }
if ($verb eq "yes" || $usage =~ /g/i){
- if ($_ =~ /conn= *([0-9]+)/i){ writeFile($CMP_CONN, $1);}
- if ($_ =~ /op= *([0-9]+)/i){ writeFile($CMP_OP, $1);}
+ if ($_ =~ /conn= *([0-9]+)/i){ push @{$arrays->{cmpconn}}, $1;}
+ if ($_ =~ /op= *([0-9]+)/i){ push @{$arrays->{cmpop}}, $1;}
}
}
if (m/ ABANDON /){
@@ -1748,9 +1698,9 @@ sub parseLineNormal
if($reportStats){ inc_stats('abandon',$s_stats,$m_stats); }
$allResults++;
if ($_ =~ /targetop= *([0-9a-zA-Z]+)/i ){
- writeFile($TARGET_OP, $1);
- if ($_ =~ /conn= *([0-9]+)/i){ writeFile($TARGET_CONN, $1); }
- if ($_ =~ /msgid= *([0-9]+)/i){ writeFile($MSGID, $1);}
+ push @{$arrays->{targetop}}, $1;
+ if ($_ =~ /conn= *([0-9]+)/i){ push @{$arrays->{targetconn}}, $1; }
+ if ($_ =~ /msgid= *([0-9]+)/i){ push @{$arrays->{msgid}}, $1; }
}
}
if (m/ VLV /){
@@ -1774,20 +1724,19 @@ sub parseLineNormal
if ($1 ne ""){
$tmpp = $1;
$tmpp =~ tr/A-Z/a-z/;
- writeFile($BINDLIST, $tmpp);
+ $hashes->{bindlist}->{$tmpp}++;
if($1 eq $rootDN){
$rootDNBindCount++;
}
} else {
$anonymousBindCount++;
- writeFile($BINDLIST, "Anonymous Binds");
+ $hashes->{bindlist}->{"Anonymous Binds"}++;
inc_stats('anonbind',$s_stats,$m_stats);
}
}
if (m/ connection from/){
- $exc = "no";
if ($_ =~ /connection from *([0-9A-Fa-f\.\:]+)/i ){
- for ($xxx =0; $xxx <= $#excludeIP; $xxx++){
+ for (my $xxx =0; $xxx < $#excludeIP; $xxx++){
if ($excludeIP[$xxx] eq $1){$exc = "yes";}
}
if ($exc ne "yes"){
@@ -1801,11 +1750,13 @@ sub parseLineNormal
}
($connID) = $_ =~ /conn=(\d*)\s/;
$openConnection[$connID]++;
- ($time, $tzone) = split (' ', $_);
- ($date, $hr, $min, $sec) = split (':', $time);
- ($day, $mon, $yr) = split ('/', $date);
- $day =~ s/\[//;
- $start_time_of_connection[$connID] = timegm($sec, $min, $hours, $day, $monthname{$mon},
$yr);
+ if ($reportStats or ($verb eq "yes") || ($usage =~ /y/)) {
+ my ($time, $tzone) = split (' ', $_);
+ my ($date, $hr, $min, $sec) = split (':', $time);
+ my ($day, $mon, $yr) = split ('/', $date);
+ $day =~ s/\[//;
+ $start_time_of_connection[$connID] = timegm($sec, $min, $hr, $day, $monthname{$mon},
$yr);
+ }
}
if (m/ SSL client bound as /){$sslClientBindCount++;}
if (m/ SSL failed to map client certificate to LDAP DN/){$sslClientFailedCount++;}
@@ -1816,16 +1767,22 @@ sub parseLineNormal
($connID) = $_ =~ /conn=(\d*)\s/;
$openConnection[$connID]--;
- $end_time_of_connection[$connID] = $gmtime;
- $diff = $end_time_of_connection[$connID] - $start_time_of_connection[$connID];
- $start_time_of_connection[$connID] = $end_time_of_connection[$connID] = 0;
- if ($diff <= 1) { $latency[0]++;}
- if ($diff == 2) { $latency[1]++;}
- if ($diff == 3) { $latency[2]++;}
- if ($diff >= 4 && $diff <=5 ) { $latency[3]++;}
- if ($diff >= 6 && $diff <=10 ) { $latency[4]++;}
- if ($diff >= 11 && $diff <=15 ) { $latency[5]++;}
- if ($diff >= 16) { $latency[6] ++;}
+ if ($reportStats or ($verb eq "yes") || ($usage =~ /y/)) {
+ # if we didn't see the start time of this connection
+ # i.e. due to truncation or log rotation
+ # then just set to 0
+ my $stoc = $start_time_of_connection[$connID] || 0;
+ $end_time_of_connection[$connID] = $gmtime || 0;
+ my $diff = $end_time_of_connection[$connID] - $stoc;
+ $start_time_of_connection[$connID] = $end_time_of_connection[$connID] = 0;
+ if ($diff <= 1) { $latency[0]++;}
+ if ($diff == 2) { $latency[1]++;}
+ if ($diff == 3) { $latency[2]++;}
+ if ($diff >= 4 && $diff <=5 ) { $latency[3]++;}
+ if ($diff >= 6 && $diff <=10 ) { $latency[4]++;}
+ if ($diff >= 11 && $diff <=15 ) { $latency[5]++;}
+ if ($diff >= 16) { $latency[6] ++;}
+ }
}
if (m/ BIND/ && $_ =~ /dn=\"(.*)\" method/i ){
if($reportStats){ inc_stats('bind',$s_stats,$m_stats); }
@@ -1834,25 +1791,26 @@ sub parseLineNormal
if($1 eq $rootDN){$rootDNBindCount++;}
$tmpp = $1;
$tmpp =~ tr/A-Z/a-z/;
- writeFile($BINDLIST, $tmpp);
- $bindVal = $tmpp;
- if ($_ =~ /conn= *([0-9]+)/i) { $bindConn = $1; writeFile($BIND_CONN, $1);}
- if ($_ =~ /op= *([0-9]+)/i) { $bindOp = $1; writeFile($BIND_OP, $1);}
+ $hashes->{bindlist}->{$tmpp}++;
+ if ($_ =~ /conn= *([0-9]+)/i) { push @{$arrays->{bindconn}}, $1;}
+ if ($_ =~ /op= *([0-9]+)/i) { push @{$arrays->{bindop}}, $1;}
if($usage =~ /f/ || $verb eq "yes"){
- # only need this for the failed bind report
- writeFile($BINDINFO, "$bindVal ,, $bindConn ,, $bindOp");
+ push @{$arrays->{binddn}}, $tmpp;
}
} else {
$anonymousBindCount++;
- writeFile($BINDLIST, "Anonymous Binds");
+ $hashes->{bindlist}->{"Anonymous Binds"}++;
+ if ($_ =~ /conn= *([0-9]+)/i) { push @{$arrays->{bindconn}}, $1;}
+ if ($_ =~ /op= *([0-9]+)/i) { push @{$arrays->{bindop}}, $1;}
+ push @{$arrays->{binddn}}, "";
inc_stats('anonbind',$s_stats,$m_stats);
}
}
if (m/ UNBIND/){
$unbindCount++;
if ($verb eq "yes"){
- if ($_ =~ /conn= *([0-9]+)/i){ writeFile($UNBIND_CONN, $1); }
- if ($_ =~ /op= *([0-9]+)/i){ writeFile($UNBIND_OP, $1); }
+ if ($_ =~ /conn= *([0-9]+)/i){ push @{$arrays->{unbindconn}}, $1; }
+ if ($_ =~ /op= *([0-9]+)/i){ push @{$arrays->{unbindop}}, $1; }
}
}
if (m/ RESULT err=/ && m/ notes=P/){
@@ -1863,7 +1821,7 @@ sub parseLineNormal
$con = $1;
if ($_ =~ /op= *([0-9]+)/i){ $op = $1;}
}
- for ($i=0; $i <= $vlvCount;$i++){
+ for (my $i=0; $i <= $vlvCount;$i++){
if ($vlvconn[$i] eq $con && $vlvop[$i] eq $op){ $vlvNotesACount++;
$isVlvNotes="1";}
}
if($isVlvNotes == 0){
@@ -1873,22 +1831,12 @@ sub parseLineNormal
if($reportStats){ inc_stats('notesA',$s_stats,$m_stats); }
}
if ($usage =~ /u/ || $verb eq "yes"){
- if ($isVlvNnotes == 0 ){
- if ($_ =~ /etime= *([0-9.]+)/i ){
- writeFile($NOTES_A_ETIME, $1);
- }
- if ($_ =~ /conn= *([0-9]+)/i){
- writeFile($NOTES_A_CONN, $1);
- }
- if ($_ =~ /op= *([0-9]+)/i){
- writeFile($NOTES_A_OP, $1);
- }
- if ($_ =~ / *([0-9a-z:\/]+)/i){
- writeFile($NOTES_A_TIME, $1);
- }
- if ($_ =~ /nentries= *([0-9]+)/i ){
- writeFile($NOTES_A_NENTRIES, $1);
- }
+ if ($isVlvNotes == 0 ){
+ if ($_ =~ /etime= *([0-9.]+)/i ){ push @{$arrays->{notesAetime}}, $1; }
+ if ($_ =~ /conn= *([0-9]+)/i){ push @{$arrays->{notesAconn}}, $1; }
+ if ($_ =~ /op= *([0-9]+)/i){ push @{$arrays->{notesAop}}, $1; }
+ if ($_ =~ / *([0-9a-z:\/]+)/i){ push @{$arrays->{notesAtime}}, $1; }
+ if ($_ =~ /nentries= *([0-9]+)/i ){ push @{$arrays->{notesAnentries}}, $1; }
}
}
$isVlvNotes = 0;
@@ -1898,7 +1846,7 @@ sub parseLineNormal
$con = $1;
if ($_ =~ /op= *([0-9]+)/i){ $op = $1;}
}
- for ($i=0; $i <= $vlvCount;$i++){
+ for (my $i=0; $i <= $vlvCount;$i++){
if ($vlvconn[$i] eq $con && $vlvop[$i] eq $op){ $vlvNotesUCount++;
$isVlvNotes="1";}
}
if($isVlvNotes == 0){
@@ -1908,85 +1856,75 @@ sub parseLineNormal
if($reportStats){ inc_stats('notesU',$s_stats,$m_stats); }
}
if ($usage =~ /u/ || $verb eq "yes"){
- if ($isVlvNnotes == 0 ){
- if ($_ =~ /etime= *([0-9.]+)/i ){
- writeFile($NOTES_U_ETIME, $1);
- }
- if ($_ =~ /conn= *([0-9]+)/i){
- writeFile($NOTES_U_CONN, $1);
- }
- if ($_ =~ /op= *([0-9]+)/i){
- writeFile($NOTES_U_OP, $1);
- }
- if ($_ =~ / *([0-9a-z:\/]+)/i){
- writeFile($NOTES_U_TIME, $1);
- }
- if ($_ =~ /nentries= *([0-9]+)/i ){
- writeFile($NOTES_U_NENTRIES, $1);
- }
+ if ($isVlvNotes == 0 ){
+ if ($_ =~ /etime= *([0-9.]+)/i ){ push @{$arrays->{notesUetime}}, $1; }
+ if ($_ =~ /conn= *([0-9]+)/i){ push @{$arrays->{notesUconn}}, $1; }
+ if ($_ =~ /op= *([0-9]+)/i){ push @{$arrays->{notesUop}}, $1; }
+ if ($_ =~ / *([0-9a-z:\/]+)/i){ push @{$arrays->{notesUtime}}, $1; }
+ if ($_ =~ /nentries= *([0-9]+)/i ){ push @{$arrays->{notesUnentries}}, $1; }
}
}
$isVlvNotes = 0;
}
if (m/ closed error 32/){
$brokenPipeCount++;
- if (m/- T1/){ writeFile($RC,"T1"); }
- elsif (m/- T2/){ writeFile($RC,"T2"); }
- elsif (m/- A1/){ writeFile($RC,"A1"); }
- elsif (m/- B1/){ writeFile($RC,"B1"); }
- elsif (m/- B4/){ writeFile($RC,"B4"); }
- elsif (m/- B2/){ writeFile($RC,"B2"); }
- elsif (m/- B3/){ writeFile($RC,"B3"); }
- elsif (m/- R1/){ writeFile($RC,"R1"); }
- elsif (m/- P1/){ writeFile($RC,"P1"); }
- elsif (m/- P1/){ writeFile($RC,"P2"); }
- elsif (m/- U1/){ writeFile($RC,"U1"); }
- else { writeFile($RC,"other"); }
+ if (m/- T1/){ $hashes->{rc}->{"T1"}++; }
+ elsif (m/- T2/){ $hashes->{rc}->{"T2"}++; }
+ elsif (m/- A1/){ $hashes->{rc}->{"A1"}++; }
+ elsif (m/- B1/){ $hashes->{rc}->{"B1"}++; }
+ elsif (m/- B4/){ $hashes->{rc}->{"B4"}++; }
+ elsif (m/- B2/){ $hashes->{rc}->{"B2"}++; }
+ elsif (m/- B3/){ $hashes->{rc}->{"B3"}++; }
+ elsif (m/- R1/){ $hashes->{rc}->{"R1"}++; }
+ elsif (m/- P1/){ $hashes->{rc}->{"P1"}++; }
+ elsif (m/- P1/){ $hashes->{rc}->{"P2"}++; }
+ elsif (m/- U1/){ $hashes->{rc}->{"U1"}++; }
+ else { $hashes->{rc}->{"other"}++; }
}
if (m/ closed error 131/ || m/ closed error -5961/){
$connResetByPeerCount++;
- if (m/- T1/){ writeFile($SRC,"T1"); }
- elsif (m/- T2/){ writeFile($SRC,"T2"); }
- elsif (m/- A1/){ writeFile($SRC,"A1"); }
- elsif (m/- B1/){ writeFile($SRC,"B1"); }
- elsif (m/- B4/){ writeFile($SRC,"B4"); }
- elsif (m/- B2/){ writeFile($SRC,"B2"); }
- elsif (m/- B3/){ writeFile($SRC,"B3"); }
- elsif (m/- R1/){ writeFile($SRC,"R1"); }
- elsif (m/- P1/){ writeFile($SRC,"P1"); }
- elsif (m/- P1/){ writeFile($SRC,"P2"); }
- elsif (m/- U1/){ writeFile($SRC,"U1"); }
- else { writeFile($SRC,"other"); }
+ if (m/- T1/){ $hashes->{src}->{"T1"}++; }
+ elsif (m/- T2/){ $hashes->{src}->{"T2"}++; }
+ elsif (m/- A1/){ $hashes->{src}->{"A1"}++; }
+ elsif (m/- B1/){ $hashes->{src}->{"B1"}++; }
+ elsif (m/- B4/){ $hashes->{src}->{"B4"}++; }
+ elsif (m/- B2/){ $hashes->{src}->{"B2"}++; }
+ elsif (m/- B3/){ $hashes->{src}->{"B3"}++; }
+ elsif (m/- R1/){ $hashes->{src}->{"R1"}++; }
+ elsif (m/- P1/){ $hashes->{src}->{"P1"}++; }
+ elsif (m/- P1/){ $hashes->{src}->{"P2"}++; }
+ elsif (m/- U1/){ $hashes->{src}->{"U1"}++; }
+ else { $hashes->{src}->{"other"}++; }
}
if (m/ closed error 11/){
$resourceUnavailCount++;
- if (m/- T1/){ writeFile($RSRC,"T1"); }
- elsif (m/- T2/){ writeFile($RSRC,"T2"); }
- elsif (m/- A1/){ writeFile($RSRC,"A1"); }
- elsif (m/- B1/){ writeFile($RSRC,"B1"); }
- elsif (m/- B4/){ writeFile($RSRC,"B4"); }
- elsif (m/- B2/){ writeFile($RSRC,"B2"); }
- elsif (m/- B3/){ writeFile($RSRC,"B3"); }
- elsif (m/- R1/){ writeFile($RSRC,"R1"); }
- elsif (m/- P1/){ writeFile($RSRC,"P1"); }
- elsif (m/- P1/){ writeFile($RSRC,"P2"); }
- elsif (m/- U1/){ writeFile($RSRC,"U1"); }
- else { writeFile($RSRC,"other"); }
+ if (m/- T1/){ $hashes->{rsrc}->{"T1"}++; }
+ elsif (m/- T2/){ $hashes->{rsrc}->{"T2"}++; }
+ elsif (m/- A1/){ $hashes->{rsrc}->{"A1"}++; }
+ elsif (m/- B1/){ $hashes->{rsrc}->{"B1"}++; }
+ elsif (m/- B4/){ $hashes->{rsrc}->{"B4"}++; }
+ elsif (m/- B2/){ $hashes->{rsrc}->{"B2"}++; }
+ elsif (m/- B3/){ $hashes->{rsrc}->{"B3"}++; }
+ elsif (m/- R1/){ $hashes->{rsrc}->{"R1"}++; }
+ elsif (m/- P1/){ $hashes->{rsrc}->{"P1"}++; }
+ elsif (m/- P1/){ $hashes->{rsrc}->{"P2"}++; }
+ elsif (m/- U1/){ $hashes->{rsrc}->{"U1"}++; }
+ else { $hashes->{rsrc}->{"other"}++; }
}
if ($usage =~ /g/ || $usage =~ /c/ || $usage =~ /i/ || $verb eq "yes"){
$exc = "no";
if ($_ =~ /connection from *([0-9A-fa-f\.\:]+)/i ) {
- for ($xxx = 0; $xxx <= $#excludeIP; $xxx++){
+ for (my $xxx = 0; $xxx < $#excludeIP; $xxx++){
if ($1 eq $excludeIP[$xxx]){
$exc = "yes";
- writeFile($EXCOUNT,$1);
+ $hashes->{excount}->{$1}++;
}
}
$ip = $1;
- writeFile($IP_HASH, "$ip count");
+ $hashes->{ip_hash}->{$ip}++;
if ($_ =~ /conn= *([0-9]+)/i ){
if ($exc ne "yes"){
- writeFile($CONN_HASH, "$1 $ip");
+ $hashes->{conn_hash}->{$1} = $ip;
}
}
}
@@ -1995,12 +1933,12 @@ sub parseLineNormal
$exc = "no";
$ip = getIPfromConn($1);
if ($ip eq ""){$ip = "Unknown_Host";}
- for ($xxx = 0; $xxx <= $#excludeIP; $xxx++){
+ for (my $xxx = 0; $xxx < $#excludeIP; $xxx++){
if ($ip eq $excludeIP[$xxx]){$exc = "yes";}
}
if ($exc ne "yes"){
- writeFile($IP_HASH, "$ip A1");
- writeFile($CONNCOUNT, "A1");
+ $hashes->{A1}->{$ip}++;
+ $hashes->{conncount}->{"A1"}++;
$connCodeCount++;
}
}
@@ -2010,12 +1948,12 @@ sub parseLineNormal
$exc = "no";
$ip = getIPfromConn($1);
if ($ip eq ""){$ip = "Unknown_Host";}
- for ($xxx = 0; $xxx <= $#excludeIP; $xxx++){
+ for (my $xxx = 0; $xxx < $#excludeIP; $xxx++){
if ($ip eq $excludeIP[$xxx]){$exc = "yes";}
}
if ($exc ne "yes"){
- writeFile($IP_HASH, "$ip B1");
- writeFile($CONNCOUNT, "B1");
+ $hashes->{B1}->{$ip}++;
+ $hashes->{conncount}->{"B1"}++;
$connCodeCount++;
}
}
@@ -2025,12 +1963,12 @@ sub parseLineNormal
$exc = "no";
$ip = getIPfromConn($1);
if ($ip eq ""){$ip = "Unknown_Host";}
- for ($xxx = 0; $xxx <= $#excludeIP; $xxx++){
+ for (my $xxx = 0; $xxx < $#excludeIP; $xxx++){
if ($ip eq $excludeIP[$xxx]){$exc = "yes";}
}
if ($exc ne "yes"){
- writeFile($IP_HASH, "$ip B4");
- writeFile($CONNCOUNT, "B4");
+ $hashes->{B4}->{$ip}++;
+ $hashes->{conncount}->{"B4"}++;
$connCodeCount++;
}
}
@@ -2040,12 +1978,12 @@ sub parseLineNormal
$exc = "no";
$ip = getIPfromConn($1);
if ($ip eq ""){$ip = "Unknown_Host";}
- for ($xxx = 0; $xxx <= $#excludeIP; $xxx++){
+ for (my $xxx = 0; $xxx < $#excludeIP; $xxx++){
if ($ip eq $excludeIP[$xxx]){$exc = "yes";}
}
if ($exc ne "yes"){
- writeFile($IP_HASH, "$ip T1");
- writeFile($CONNCOUNT, "T1");
+ $hashes->{T1}->{$ip}++;
+ $hashes->{conncount}->{"T1"}++;
$connCodeCount++;
}
}
@@ -2055,12 +1993,12 @@ sub parseLineNormal
$exc = "no";
$ip = getIPfromConn($1);
if ($ip eq ""){$ip = "Unknown_Host";}
- for ($xxx = 0; $xxx <= $#excludeIP; $xxx++){
+ for (my $xxx = 0; $xxx < $#excludeIP; $xxx++){
if ($ip eq $excludeIP[$xxx]){$exc = "yes";}
}
if ($exc ne "yes"){
- writeFile($IP_HASH, "$ip T2");
- writeFile($CONNCOUNT, "T2");
+ $hashes->{T2}->{$ip}++;
+ $hashes->{conncount}->{"T2"}++;
$connCodeCount++;
}
}
@@ -2071,12 +2009,12 @@ sub parseLineNormal
$ip = getIPfromConn($1);
$maxBerSizeCount++;
if ($ip eq ""){$ip = "Unknown_Host";}
- for ($xxx = 0; $xxx <= $#excludeIP; $xxx++){
+ for (my $xxx = 0; $xxx < $#excludeIP; $xxx++){
if ($ip eq $excludeIP[$xxx]){$exc = "yes";}
}
if ($exc ne "yes"){
- writeFile($IP_HASH, "$ip B2");
- writeFile($CONNCOUNT, "B2");
+ $hashes->{B2}->{$ip}++;
+ $hashes->{conncount}->{"B2"}++;
$connCodeCount++;
}
}
@@ -2086,12 +2024,12 @@ sub parseLineNormal
$exc = "no";
$ip = getIPfromConn($1);
if ($ip eq ""){$ip = "Unknown_Host";}
- for ($xxx = 0; $xxx <= $#excludeIP; $xxx++){
+ for (my $xxx = 0; $xxx < $#excludeIP; $xxx++){
if ($ip eq $excludeIP[$xxx]){$exc = "yes";}
}
if ($exc ne "yes"){
- writeFile($IP_HASH, "$ip B3");
- writeFile($CONNCOUNT, "B3");
+ $hashes->{B3}->{$ip}++;
+ $hashes->{conncount}->{"B3"}++;
$connCodeCount++;
}
}
@@ -2101,12 +2039,12 @@ sub parseLineNormal
$exc = "no";
$ip = getIPfromConn($1);
if ($ip eq ""){$ip = "Unknown_Host";}
- for ($xxx = 0; $xxx <= $#excludeIP; $xxx++){
+ for (my $xxx = 0; $xxx < $#excludeIP; $xxx++){
if ($ip eq $excludeIP[$xxx]){$exc = "yes";}
}
if ($exc ne "yes"){
- writeFile($IP_HASH, "$ip R1");
- writeFile($CONNCOUNT, "R1");
+ $hashes->{R1}->{$ip}++;
+ $hashes->{conncount}->{"R1"}++;
$connCodeCount++;
}
}
@@ -2116,12 +2054,12 @@ sub parseLineNormal
$exc = "no";
$ip = getIPfromConn($1);
if ($ip eq ""){$ip = "Unknown_Host";}
- for ($xxx = 0; $xxx <= $#excludeIP; $xxx++){
+ for (my $xxx = 0; $xxx < $#excludeIP; $xxx++){
if ($ip eq $excludeIP[$xxx]){$exc = "yes";}
}
if ($exc ne "yes"){
- writeFile($IP_HASH, "$ip P1");
- writeFile($CONNCOUNT, "P1");
+ $hashes->{P1}->{$ip}++;
+ $hashes->{conncount}->{"P1"}++;
$connCodeCount++;
}
}
@@ -2131,12 +2069,12 @@ sub parseLineNormal
$exc = "no";
$ip = getIPfromConn($1);
if ($ip eq ""){$ip = "Unknown_Host";}
- for ($xxx = 0; $xxx <= $#excludeIP; $xxx++){
+ for (my $xxx = 0; $xxx < $#excludeIP; $xxx++){
if ($ip eq $excludeIP[$xxx]){$exc = "yes";}
}
if ($exc ne "yes"){
- writeFile($IP_HASH, "$ip P2");
- writeFile($CONNCOUNT, "P2");
+ $hashes->{P2}->{$ip}++;
+ $hashes->{conncount}->{"P2"}++;
$connCodeCount++;
}
}
@@ -2146,12 +2084,12 @@ sub parseLineNormal
$exc = "no";
$ip = getIPfromConn($1);
if ($ip eq ""){$ip = "Unknown_Host";}
- for ($xxx = 0; $xxx <= $#excludeIP; $xxx++){
+ for (my $xxx = 0; $xxx < $#excludeIP; $xxx++){
if ($ip eq $excludeIP[$xxx]){$exc = "yes";}
}
if ($exc ne "yes"){
- writeFile($IP_HASH, "$ip U1");
- writeFile($CONNCOUNT, "U1");
+ $hashes->{U1}->{$ip}++;
+ $hashes->{conncount}->{"U1"}++;
$connCodeCount++;
}
}
@@ -2162,59 +2100,60 @@ sub parseLineNormal
if ($1 ne "0"){ $errorCount++;}
else { $successCount++;}
}
- if ($_ =~ /etime= *([0-9.]+)/ ) { writeFile($ETIME, $1);
inc_stats_val('etime',$1,$s_stats,$m_stats); }
+ if ($_ =~ /etime= *([0-9.]+)/ ) { $hashes->{etime}->{$1}++;
inc_stats_val('etime',$1,$s_stats,$m_stats); }
if ($_ =~ / tag=101 / || $_ =~ / tag=111 / || $_ =~ / tag=100 / || $_ =~ / tag=115 /){
- if ($_ =~ / nentries= *([0-9]+)/i ){ writeFile($NENTRIES, $1); }
+ if ($_ =~ / nentries= *([0-9]+)/i ){ $hashes->{nentries}->{$1}++; }
}
if (m/objectclass=\*/i || m/objectclass=top/i ){
if (m/ scope=2 /){ $objectclassTopCount++;}
}
if (m/ EXT oid=/){
$extopCount++;
- if ($_ =~ /oid=\" *([0-9\.]+)/i ){ writeFile($OID,$1); }
+ if ($_ =~ /oid=\" *([0-9\.]+)/i ){ $hashes->{oid}->{$1}++; }
if ($1 && $1 eq $startTLSoid){$startTLSCount++;}
if ($verb eq "yes"){
- if ($_ =~ /conn= *([0-9]+)/i){ writeFile($EXT_CONN, $1); }
- if ($_ =~ /op= *([0-9]+)/i){ writeFile($EXT_OP, $1); }
+ if ($_ =~ /conn= *([0-9]+)/i){ push @{$arrays->{extconn}}, $1; }
+ if ($_ =~ /op= *([0-9]+)/i){ push @{$arrays->{extop}}, $1; }
}
}
- if ($usage =~ /l/ || $verb eq "yes"){
+ if (($usage =~ /l/ || $verb eq "yes") and / SRCH /){
+ my ($filterConn, $filterOp);
if (/ SRCH / && / attrs=/ && $_ =~ /filter=\"(.*)\" /i ){
$tmpp = $1;
$tmpp =~ tr/A-Z/a-z/;
$tmpp =~ s/\\22/\"/g;
- writeFile($FILTER, $tmpp);
- $filterVal = $tmpp;
+ $hashes->{filter}->{$tmpp}++;
if ($_ =~ /conn= *([0-9]+)/i) { $filterConn = $1; }
if ($_ =~ /op= *([0-9]+)/i) { $filterOp = $1; }
} elsif (/ SRCH / && $_ =~ /filter=\"(.*)\"/i){
$tmpp = $1;
$tmpp =~ tr/A-Z/a-z/;
$tmpp =~ s/\\22/\"/g;
- writeFile($FILTER, $tmpp);
- $filterVal = $tmpp;
+ $hashes->{filter}->{$tmpp}++;
if ($_ =~ /conn= *([0-9]+)/i) { $filterConn = $1; }
if ($_ =~ /op= *([0-9]+)/i) { $filterOp = $1; }
}
$filterCount++;
if($usage =~ /u/ || $verb eq "yes"){
- # we noly need this for the unindexed search report
- writeFile($FILTERINFO, "$filterVal ,, $filterConn ,, $filterOp");
+ # we only need this for the unindexed search report
+ push @{$arrays->{filterval}}, $tmpp;
+ push @{$arrays->{filterconn}}, $filterConn;
+ push @{$arrays->{filterop}}, $filterOp;
}
}
if ($usage =~ /a/ || $verb eq "yes"){
if (/ SRCH / && $_ =~ /base=\"(.*)\" scope/i ){
+ my ($baseConn, $baseOp, $scopeVal, $scopeConn, $scopeOp);
if ($1 eq ""){
$tmpp = "Root DSE";
} else {
$tmpp = $1;
}
$tmpp =~ tr/A-Z/a-z/;
- writeFile($BASE, $tmpp);
+ $hashes->{base}->{$tmpp}++;
#
# grab the search bases & scope for potential unindexed searches
#
- $baseVal = $tmpp;
if ($_ =~ /scope= *([0-9]+)/i) {
$scopeVal = $1;
}
@@ -2227,9 +2166,13 @@ sub parseLineNormal
$scopeOp = $1;
}
if($usage =~ /u/ || $verb eq "yes"){
- # we noly need this for the unindexed search report
- writeFile($BASEINFO, "$baseVal ,, $baseConn ,, $baseOp");
- writeFile($SCOPEINFO, "$scopeVal ,, $scopeConn ,, $scopeOp");
+ # we only need this for the unindexed search report
+ push @{$arrays->{baseval}}, $tmpp;
+ push @{$arrays->{baseconn}}, $baseConn;
+ push @{$arrays->{baseop}}, $baseOp;
+ push @{$arrays->{scopeval}}, $scopeVal;
+ push @{$arrays->{scopeconn}}, $scopeConn;
+ push @{$arrays->{scopeop}}, $scopeOp;
}
$baseCount++;
$scopeCount++;
@@ -2243,26 +2186,26 @@ sub parseLineNormal
if ($usage =~ /f/ || $verb eq "yes"){
if (/ err=49 tag=/ && / dn=\"/){
if ($_ =~ /dn=\"(.*)\"/i ){
- writeFile($DS6XBADPWD, $1);
+ $hashes->{ds6xbadpwd}->{$1}++;
}
$ds6x = "true";
$badPwdCount++;
} elsif (/ err=49 tag=/ ){
if ($_ =~ /conn= *([0-9]+)/i ){
- writeFile($BADPWDCONN, $1);
+ push @{$arrays->{badpwdconn}}, $1;
$ip = getIPfromConn($1);
$badPwdCount++;
}
if ($_ =~ /op= *([0-9]+)/i ){
- writeFile($BADPWDOP, $1);
+ push @{$arrays->{badpwdop}}, $1;
}
- writeFile($BADPWDIP, $ip);
+ push @{$arrays->{badpwdip}}, $ip;
}
}
if (/ BIND / && /method=sasl/i){
$saslBindCount++;
- if ($_ =~ /mech=(.*)/i ){
- writeFile($SASLMECH, $1);
+ if ($_ =~ /mech=(.*)/i ){
+ $hashes->{saslmech}->{$1}++;
}
}
if (/ conn=Internal op=-1 / && !/ RESULT err=/){ $internalOpCount++; }
@@ -2414,7 +2357,7 @@ displayBindReport
print "\nBind Report\n";
print
"====================================================================\n\n";
- foreach $bindDN (sort { $bindReport{$a} <=> $bindReport{$b} } keys %bindReport) {
+ foreach my $bindDN (sort { $bindReport{$a} <=> $bindReport{$b} } keys %bindReport)
{
print("Bind DN: $bindDN\n");
print("--------------------------------------------------------------------\n");
print(" Client Addresses:\n\n");
@@ -2430,11 +2373,11 @@ displayBindReport
sub
printClients
{
- @bindConns = &cleanConns(split(' ', @_[0]));
- $IPcount = "1";
+ my @bindConns = &cleanConns(split(' ', $_[0]));
+ my $IPcount = "1";
- foreach $ip ( keys %connList ){ # Loop over all the IP addresses
- foreach $bc (@bindConns){ # Loop over each bind conn number and compare it
+ foreach my $ip ( keys %connList ){ # Loop over all the IP addresses
+ foreach my $bc (@bindConns){ # Loop over each bind conn number and compare it
if($connList{$ip} =~ / $bc /){
print(" [$IPcount] $ip\n");
$IPcount++;
@@ -2447,22 +2390,22 @@ printClients
sub
cleanConns
{
- @dirtyConns = @_;
- $#cleanConns = -1;
- $c = 0;
+ my @dirtyConns = @_;
+ my @retConns = ();
+ my $c = 0;
- for ($i = 0; $i <=$#dirtyConns; $i++){
+ for (my $i = 0; $i <=$#dirtyConns; $i++){
if($dirtyConns[$i] ne ""){
- $cleanConns[$c++] = $dirtyConns[$i];
+ $retConns[$c++] = $dirtyConns[$i];
}
}
- return @cleanConns;
+ return @retConns;
}
sub
printOpStats
{
- $dn = @_[0];
+ my $dn = $_[0];
if( $bindReport{$dn}{"failedBind"} == 0 ){
print(" Binds: " . $bindReport{$dn}{"binds"} .
"\n");
@@ -2487,333 +2430,70 @@ printOpStats
sub
openFailed
{
- $open_error = @_[0];
- $file_name = @_[1];
- closeDataFiles();
+ my $open_error = $_[0];
+ my $file_name = $_[1];
removeDataFiles();
die ("Can not open $file_name error ($open_error)");
}
sub
-openDataFiles
+openHashFiles
{
- # hash files
- open ($ATTR, ">$ATTR") or do { openFailed($!, $ATTR) };
- open ($RC, ">$RC") or do { openFailed($!, $RC) };
- open ($SRC, ">$SRC") or do { openFailed($!, $SRC) };
- open ($RSRC, ">$RSRC") or do { openFailed($!, $RSRC) };
- open ($EXCOUNT, ">$EXCOUNT") or do { openFailed($!, $EXCOUNT) };
- open ($CONN_HASH, ">$CONN_HASH") or do { openFailed($!, $CONN_HASH) };
- open ($IP_HASH, ">$IP_HASH") or do { openFailed($!, $IP_HASH) };
- open ($CONNCOUNT, ">$CONNCOUNT") or do { openFailed($!, $CONNCOUNT) };
- open ($NENTRIES, ">$NENTRIES") or do { openFailed($!, $NENTRIES) };
- open ($FILTER, ">$FILTER") or do { openFailed($!, $FILTER) };
- open ($BASE, ">$BASE") or do { openFailed($!, $BASE) };
- open ($DS6XBADPWD, ">$DS6XBADPWD") or do { openFailed($!, $DS6XBADPWD) };
- open ($SASLMECH, ">$SASLMECH") or do { openFailed($!, $SASLMECH) };
- open ($BINDLIST, ">$BINDLIST") or do { openFailed($!, $BINDLIST) };
- open ($ETIME, ">$ETIME") or do { openFailed($!, $ETIME) };
- open ($OID, ">$OID") or do { openFailed($!, $OID) };
-
- # array files
- open($SRCH_CONN,">$SRCH_CONN") or do { openFailed($!, $SRCH_CONN) };
- open($SRCH_OP, ">$SRCH_OP") or do { openFailed($!, $SRCH_OP) };
- open($DEL_CONN, ">$DEL_CONN") or do { openFailed($!, $DEL_CONN) };
- open($DEL_OP, ">$DEL_OP") or do { openFailed($!, $DEL_OP) };
- open($MOD_CONN, ">$MOD_CONN") or do { openFailed($!, $MOD_CONN) };
- open($MOD_OP, ">$MOD_OP") or do { openFailed($!, $MOD_OP) };
- open($ADD_CONN, ">$ADD_CONN") or do { openFailed($!, $ADD_CONN) };
- open($ADD_OP, ">$ADD_OP") or do { openFailed($!, $ADD_OP) };
- open($MODRDN_CONN, ">$MODRDN_CONN") or do { openFailed($!, $MODRDN_CONN)
};
- open($MODRDN_OP, ">$MODRDN_OP") or do { openFailed($!, $MODRDN_OP) };
- open($CMP_CONN, ">$CMP_CONN") or do { openFailed($!, $CMP_CONN) };
- open($CMP_OP,">$CMP_OP") or do { openFailed($!, $CMP_OP) };
- open($TARGET_CONN, ">$TARGET_CONN") or do { openFailed($!, $TARGET_CONN)
};
- open($TARGET_OP, ">$TARGET_OP") or do { openFailed($!, $TARGET_OP) };
- open($MSGID, ">$MSGID") or do { openFailed($!, $MSGID) };
- open($BIND_CONN, ">$BIND_CONN") or do { openFailed($!, $BIND_CONN) };
- open($BIND_OP, ">$BIND_OP") or do { openFailed($!, $BIND_OP) };
- open($UNBIND_CONN, ">$UNBIND_CONN") or do { openFailed($!, $UNBIND_CONN)
};
- open($UNBIND_OP, ">$UNBIND_OP") or do { openFailed($!, $UNBIND_OP) };
- open($EXT_CONN, ">$EXT_CONN") or do { openFailed($!, $EXT_CONN) };
- open($EXT_OP, ">$EXT_OP") or do { openFailed($!, $EXT_OP) };
- open($NOTES_A_ETIME, ">$NOTES_A_ETIME") or do { openFailed($!,
$NOTES_A_ETIME) };
- open($NOTES_A_CONN, ">$NOTES_A_CONN") or do { openFailed($!, $NOTES_A_CONN)
};
- open($NOTES_A_OP, ">$NOTES_A_OP") or do { openFailed($!, $NOTES_A_OP) };
- open($NOTES_A_TIME, ">$NOTES_A_TIME") or do { openFailed($!, $NOTES_A_TIME)
};
- open($NOTES_A_NENTRIES, ">$NOTES_A_NENTRIES") or do { openFailed($!,
$NOTES_A_NENTRIES) };
- open($NOTES_U_ETIME, ">$NOTES_U_ETIME") or do { openFailed($!,
$NOTES_U_ETIME) };
- open($NOTES_U_CONN, ">$NOTES_U_CONN") or do { openFailed($!, $NOTES_U_CONN)
};
- open($NOTES_U_OP, ">$NOTES_U_OP") or do { openFailed($!, $NOTES_U_OP) };
- open($NOTES_U_TIME, ">$NOTES_U_TIME") or do { openFailed($!, $NOTES_U_TIME)
};
- open($NOTES_U_NENTRIES, ">$NOTES_U_NENTRIES") or do { openFailed($!,
$NOTES_U_NENTRIES) };
- open($BADPWDCONN, ">$BADPWDCONN") or do { openFailed($!, $BADPWDCONN) };
- open($BADPWDOP, ">$BADPWDOP") or do { openFailed($!, $BADPWDOP) };
- open($BADPWDIP, ">$BADPWDIP") or do { openFailed($!, $NADPWDIP) };
-
- # info files
- open($BINDINFO, ">$BINDINFO") or do { openFailed($!, $BINDINFO) };
- open($BASEINFO, ">$BASEINFO") or do { openFailed($!, $BASEINFO) };
- open($SCOPEINFO, ">$SCOPEINFO") or do { openFailed($!, $SCOPEINFO) };
- open($FILTERINFO, ">$FILTERINFO") or do { openFailed($!, $FILTERINFO) };
-}
-
-sub
-closeDataFiles
-{
- close $ATTR;
- close $RC;
- close $SRC;
- close $RSRC;
- close $EXCOUNT;
- close $CONN_HASH;
- close $IP_HASH;
- close $CONNCOUNT;
- close $NENTRIES;
- close $FILTER;
- close $BASE;
- close $DS6XBADPWD;
- close $SASLMECH;
- close $BINDLIST;
- close $ETIME;
- close $OID;
-
- # array files
- close $SRCH_CONN;
- close $SRCH_OP;
- close $DEL_CONN;
- close $DEL_OP;
- close $MOD_CONN;
- close $MOD_OP;
- close $ADD_CONN;
- close $ADD_OP;
- close $MODRDN_CONN;
- close $MODRDN_OP;
- close $CMP_CONN;
- close $CMP_OP;
- close $TARGET_CONN;
- close $TARGET_OP;
- close $MSGID;
- close $BIND_CONN;
- close $BIND_OP;
- close $UNBIND_CONN;
- close $UNBIND_OP;
- close $EXT_CONN;
- close $EXT_OP;
- close $NOTES_A_ETIME;
- close $NOTES_A_CONN;
- close $NOTES_A_OP;
- close $NOTES_A_TIME;
- close $NOTES_A_NENTRIES;
- close $NOTES_U_ETIME;
- close $NOTES_U_CONN;
- close $NOTES_U_OP;
- close $NOTES_U_TIME;
- close $NOTES_U_NENTRIES;
- close $BADPWDCONN;
- close $BADPWDOP;
- close $BADPWDIP;
-
- # info files
- close $BINDINFO;
- close $BASEINFO;
- close $SCOPEINFO;
- close $FILTERINFO;
-}
-
-sub
-removeDataFiles
-{
- unlink $ATTR;
- unlink $RC;
- unlink $SRC;
- unlink $RSRC;
- unlink $EXCOUNT;
- unlink $CONN_HASH;
- unlink $IP_HASH;
- unlink $CONNCOUNT;
- unlink $NENTRIES;
- unlink $FILTER;
- unlink $BASE;
- unlink $DS6XBADPWD;
- unlink $SASLMECH;
- unlink $BINDLIST;
- unlink $ETIME;
- unlink $OID;
-
- # array files
- unlink $SRCH_CONN;
- unlink $SRCH_OP;
- unlink $DEL_CONN;
- unlink $DEL_OP;
- unlink $MOD_CONN;
- unlink $MOD_OP;
- unlink $ADD_CONN;
- unlink $ADD_OP;
- unlink $MODRDN_CONN;
- unlink $MODRDN_OP;
- unlink $CMP_CONN;
- unlink $CMP_OP;
- unlink $TARGET_CONN;
- unlink $TARGET_OP;
- unlink $MSGID;
- unlink $BIND_CONN;
- unlink $BIND_OP;
- unlink $UNBIND_CONN;
- unlink $UNBIND_OP;
- unlink $EXT_CONN;
- unlink $EXT_OP;
- unlink $NOTES_A_ETIME;
- unlink $NOTES_A_CONN;
- unlink $NOTES_A_OP;
- unlink $NOTES_A_TIME;
- unlink $NOTES_A_NENTRIES;
- unlink $NOTES_U_ETIME;
- unlink $NOTES_U_CONN;
- unlink $NOTES_U_OP;
- unlink $NOTES_U_TIME;
- unlink $NOTES_U_NENTRIES;
- unlink $BADPWDCONN;
- unlink $BADPWDOP;
- unlink $BADPWDIP;
-
- # info files
- unlink $BINDINFO;
- unlink $BASEINFO;
- unlink $SCOPEINFO;
- unlink $FILTERINFO;
-}
-
-sub
-getIPfromConn
-{
- $connip = @_[0];
- $retval = "";
-
- close $CONN_HASH; # we can not read the file is its already open
- open(CONN,"$CONN_HASH") or do { openFailed($!, $CONN_HASH) };
- while (<CONN>){
- if($_ =~ /$connip (.*)/){
- $retval = $1;
- last;
- }
+ my $dir = shift;
+ my %hashes = ();
+ for my $hn (@_) {
+ my %h = (); # using my in inner loop will create brand new hash every time through for
tie
+ my $fn = "$dir/$hn.logconv.db";
+ push @removefiles, $fn;
+ tie %h, "DB_File", $fn, O_CREAT|O_RDWR, 0600, $DB_HASH or do { openFailed($!,
$fn) };
+ $hashes{$hn} = \%h;
}
- close CONN;
- #reopen file for writing(append)
- open($CONN_HASH,">>$CONN_HASH") or do { openFailed($!, $CONN_HASH) };
-
- return $retval;
-}
-
-sub
-writeFile
-{
- $file = @_[0];
- $text = @_[1] . "\n";
-
- print $file $text;
+ return \%hashes;
}
-# This hash file stores one value per line
sub
-getCounterHashFromFile
+openArrayFiles
{
- $file = @_[0];
- my %hash = ();
-
- open(FILE,"$file") or do { openFailed($!, $file) };
- while(<FILE>){
- chomp;
- $hash{$_}++;
+ my $dir = shift;
+ my %arrays = ();
+ for my $an (@_) {
+ my @ary = (); # using my in inner loop will create brand new array every time through
for tie
+ my $fn = "$dir/$an.logconv.db";
+ push @removefiles, $fn;
+ tie @ary, "DB_File", $fn, O_CREAT|O_RDWR, 0600, $DB_RECNO or do {
openFailed($!, $fn) };
+ $arrays{$an} = \@ary;
}
- close FILE;
-
- return %hash;
+ return \%arrays;
}
-# this hash file stores two values per line (2 dimension hash)
sub
-getTwoDimHashFromFile
+removeDataFiles
{
- $file = @_[0];
- my %hash = ();
+ if (!$needCleanup) { return ; }
- open(FILE,"$file") or do { openFailed($!, $file) };
- while(<FILE>){
- @parts = split (' ', $_);
- chomp(@parts);
- $hash{$parts[0]}{$parts[1]}++;
+ for my $h (keys %{$hashes}) {
+ untie %{$hashes->{$h}};
}
- close FILE;
-
- return %hash;
-}
-
-# this hash file stores two values per line (1 dimension hash)
-sub
-getHashFromFile
-{
- $file = @_[0];
- my %hash = ();
- @parts = ();
-
- open(FILE,"$file") or do { openFailed($!, $file ) };
- while(<FILE>){
- @parts = split (' ',$_);
- chomp(@parts);
- $hash{$parts[0]} = $parts[1];
+ for my $a (keys %{$arrays}) {
+ untie @{$arrays->{$a}};
}
- close FILE;
-
- return %hash;
-}
-
-# Return array of values from the file
-sub
-getArrayFromFile
-{
- my @arry;
- $file = @_[0];
- $array_count = 0;
-
- open(FILE,"$file") or do { openFailed($!, $file) };
- while(<FILE>){
- chomp;
- $arry[$array_count] = $_;
- $array_count++;
+ for my $file (@removefiles) {
+ unlink $file;
}
- close FILE;
-
- return @arry;
+ $needCleanup = 0;
}
-# build the three array
+END { print "Cleaning up temp files . . .\n"; removeDataFiles(); print
"Done\n"; }
+
sub
-getInfoArraysFromFile
+getIPfromConn
{
- $file = @_[0];
- $array_count = 0;
- @parts = ();
-
- open(FILE,"<$file") or do { openFailed($!, $file) };
- while(<FILE>){
- @parts = split (' ,, ',$_);
- chomp(@parts);
- if($#parts > 0){
- $fileArray1[$array_count] = $parts[0];
- $fileArray2[$array_count] = $parts[1];
- $fileArray3[$array_count] = $parts[2];
- $array_count++;
- }
- }
- close FILE;
+ my $connid = shift;
+ return $hashes->{conn_hash}->{$connid};
}
-
-
#######################################
# #
# The End #
# #
#######################################
-
commit 15c77ad6e757625cd8a57bb5cde5e8d697bf5b25
Author: Thierry bordaz (tbordaz) <tbordaz(a)redhat.com>
Date: Fri May 17 11:48:08 2013 +0200
Ticket 47354 - Indexed search are logged with 'notes=U' in the access logs
Bug Description:
In the access log, the flag "notes=U" is present to warn the customer that
the provided filter contains not
indexed components. This flag is set independently of the fact that all entries of
the database will be
evaluated against the filter. So it can not be used to determine if all the entries
have been scanned.
Evaluated all entries is usually a performance hit for large database containing
millions of entries.
Fix Description:
The fix consist to introduce a new flag 'notes=A' at the top level
(ldbm_back_search) only when the candidate
list is ALLID and all entries will be scanned.
The fix also contains the update of logconv.pl to take into account this change.
https://fedorahosted.org/389/ticket/47354
Reviewed by: Rich Megginson and Mark Reynolds (thanks to you !)
Platforms tested: Fedora 17
Flag Day: no
Doc impact: no
(cherry picked from commit f2b5a975c2268b6e99bf27b45a7380d295807d81)
diff --git a/ldap/admin/src/logconv.pl b/ldap/admin/src/logconv.pl
index 77088ff..8ae72da 100755
--- a/ldap/admin/src/logconv.pl
+++ b/ldap/admin/src/logconv.pl
@@ -157,8 +157,10 @@ print "\nCommand: logconv.pl @ARGV\n\n";
$rootDNBindCount = 0;
$anonymousBindCount = 0;
-$unindexedSrchCount = 0;
-$vlvNotesCount= 0;
+$unindexedSrchCountNotesA = 0;
+$unindexedSrchCountNotesU = 0;
+$vlvNotesACount= 0;
+$vlvNotesUCount= 0;
$srchCount = 0;
$fdTaken = 0;
$fdReturned = 0;
@@ -254,11 +256,16 @@ $UNBIND_CONN = "$dataLocation/unbindconn.logconv";
$UNBIND_OP = "$dataLocation/unbindop.logconv";
$EXT_CONN = "$dataLocation/extconn.logconv";
$EXT_OP = "$dataLocation/extop.logconv";
-$NOTES_ETIME = "$dataLocation/notesetime.logconv";
-$NOTES_CONN = "$dataLocation/notesconn.logconv";
-$NOTES_OP = "$dataLocation/notesop.logconv";
-$NOTES_TIME = "$dataLocation/notestime.logconv";
-$NOTES_NENTRIES = "$dataLocation/notesnentries.logconv";
+$NOTES_A_ETIME = "$dataLocation/notesAetime.logconv";
+$NOTES_A_CONN = "$dataLocation/notesAconn.logconv";
+$NOTES_A_OP = "$dataLocation/notesAop.logconv";
+$NOTES_A_TIME = "$dataLocation/notesAtime.logconv";
+$NOTES_A_NENTRIES = "$dataLocation/notesAnentries.logconv";
+$NOTES_U_ETIME = "$dataLocation/notesUetime.logconv";
+$NOTES_U_CONN = "$dataLocation/notesUconn.logconv";
+$NOTES_U_OP = "$dataLocation/notesUop.logconv";
+$NOTES_U_TIME = "$dataLocation/notesUtime.logconv";
+$NOTES_U_NENTRIES = "$dataLocation/notesUnentries.logconv";
$BADPWDCONN = "$dataLocation/badpwdconn.logconv";
$BADPWDOP = "$dataLocation/badpwdop.logconv";
$BADPWDIP = "$dataLocation/badpwdip.logconv";
@@ -641,20 +648,22 @@ print "Abandoned Requests: $abandonCount\n";
print "Smart Referrals Received: $referralCount\n";
print "\n";
print "VLV Operations: $vlvCount\n";
-print "VLV Unindexed Searches: $vlvNotesCount\n";
+print "VLV Unindexed Searches: $vlvNotesACount\n";
+print "VLV Unindexed Components: $vlvNotesUCount\n";
print "SORT Operations: $vlvSortCount\n";
print "\n";
print "Entire Search Base Queries: $objectclassTopCount\n";
print "Paged Searches: $pagedSearchCount\n";
-print "Unindexed Searches: $unindexedSrchCount\n";
+print "Unindexed Searches: $unindexedSrchCountNotesA\n";
+print "Unindexed Components: $unindexedSrchCountNotesU\n";
if ($verb eq "yes" || $usage =~ /u/){
- if ($unindexedSrchCount > 0){
+ if ($unindexedSrchCountNotesA > 0){
%conn_hash = getHashFromFile($CONN_HASH);
- @notesConn = getArrayFromFile($NOTES_CONN);
- @notesOp = getArrayFromFile($NOTES_OP);
- @notesEtime = getArrayFromFile($NOTES_ETIME);
- @notesTime = getArrayFromFile($NOTES_TIME);
- @notesNentries = getArrayFromFile($NOTES_NENTRIES);
+ @notesConn = getArrayFromFile($NOTES_A_CONN);
+ @notesOp = getArrayFromFile($NOTES_A_OP);
+ @notesEtime = getArrayFromFile($NOTES_A_ETIME);
+ @notesTime = getArrayFromFile($NOTES_A_TIME);
+ @notesNentries = getArrayFromFile($NOTES_A_NENTRIES);
getInfoArraysFromFile($BASEINFO);
@base_val = @fileArray1;
@base_conn = @fileArray2;
@@ -720,6 +729,78 @@ if ($verb eq "yes" || $usage =~ /u/){
undef @scope_conn;
undef @scope_op;
}
+ if ($unindexedSrchCountNotesU > 0){
+ %conn_hash = getHashFromFile($CONN_HASH);
+ @notesConn = getArrayFromFile($NOTES_U_CONN);
+ @notesOp = getArrayFromFile($NOTES_U_OP);
+ @notesEtime = getArrayFromFile($NOTES_U_ETIME);
+ @notesTime = getArrayFromFile($NOTES_U_TIME);
+ @notesNentries = getArrayFromFile($NOTES_U_NENTRIES);
+ getInfoArraysFromFile($BASEINFO);
+ @base_val = @fileArray1;
+ @base_conn = @fileArray2;
+ @base_op = @fileArray3;
+ getInfoArraysFromFile($SCOPEINFO);
+ @scope_val = @fileArray1;
+ @scope_conn = @fileArray2;
+ @scope_op = @fileArray3;
+ getInfoArraysFromFile($FILTERINFO);
+ @filter_val = @fileArray1;
+ @filter_conn = @fileArray2;
+ @filter_op = @fileArray3;
+
+ $notesCount = "1";
+ for ($n = 0; $n <= $#notesEtime; $n++){
+ @alreadyseenDN = ();
+ if($conn_hash{$notesConn[$n]} eq ""){
+ $unindexedIp = "?";
+ } else {
+ $unindexedIp = $conn_hash{$notesConn[$n]};
+ }
+ print "\n Unindexed Components #".$notesCount."\n";
$notesCount++;
+ print " - Date/Time: $notesTime[$n]\n";
+ print " - Connection Number: $notesConn[$n]\n";
+ print " - Operation Number: $notesOp[$n]\n";
+ print " - Etime: $notesEtime[$n]\n";
+ print " - Nentries: $notesNentries[$n]\n";
+ print " - IP Address: $unindexedIp\n";
+
+ for ($nnn = 0; $nnn < $baseCount; $nnn++){
+ if ($notesConn[$n] eq $base_conn[$nnn] && $notesOp[$n] eq $base_op[$nnn]){
+ print " - Search Base: $base_val[$nnn]\n";
+ last;
+ }
+ }
+ for ($nnn = 0; $nnn < $scopeCount; $nnn++){
+ if ($notesConn[$n] eq $scope_conn[$nnn] && $notesOp[$n] eq $scope_op[$nnn]){
+ print " - Search Scope: $scope_val[$nnn]\n";
+ last;
+ }
+ }
+ for ($nnn = 0; $nnn < $filterCount; $nnn++){
+ if ($notesConn[$n] eq $filter_conn[$nnn] && $notesOp[$n] eq
$filter_op[$nnn]){
+ print " - Search Filter: $filter_val[$nnn]\n";
+ last;
+ }
+ }
+ }
+ undef %conn_hash;
+ undef @notesConn;
+ undef @notesOp;
+ undef @notesEtime;
+ undef @notesTime;
+ undef @notesNentries;
+ undef @notesIp;
+ undef @filter_val;
+ undef @filter_conn;
+ undef @filter_op;
+ undef @base_val;
+ undef @base_conn;
+ undef @base_op;
+ undef @scope_val;
+ undef @scope_conn;
+ undef @scope_op;
+ }
} # end of unindexed search report
print "\n";
@@ -1276,10 +1357,14 @@ if ($usage =~ /j/i || $verb eq "yes"){
%conncount = getCounterHashFromFile($CONNCOUNT);
print "\n----- Recommendations -----\n";
$recCount = "1";
- if ($unindexedSrchCount > 0){
+ if ($unindexedSrchCountNotesA > 0){
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";
$recCount++;
}
+ if ($unindexedSrchCountNotesU > 0){
+ 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";
+ $recCount++;
+ }
if ($conncount{"T1"} > 0){
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";
$recCount++;
@@ -1773,36 +1858,71 @@ sub parseLineNormal
if (m/ RESULT err=/ && m/ notes=P/){
$pagedSearchCount++;
}
+ if (m/ notes=A/){
+ if ($_ =~ /conn= *([0-9]+)/i){
+ $con = $1;
+ if ($_ =~ /op= *([0-9]+)/i){ $op = $1;}
+ }
+ for ($i=0; $i <= $vlvCount;$i++){
+ if ($vlvconn[$i] eq $con && $vlvop[$i] eq $op){ $vlvNotesACount++;
$isVlvNotes="1";}
+ }
+ if($isVlvNotes == 0){
+ # We don't want to record vlv unindexed searches for our regular "bad"
+ # unindexed search stat, as VLV unindexed searches aren't that bad
+ $unindexedSrchCountNotesA++;
+ if($reportStats){ inc_stats('notesA',$s_stats,$m_stats); }
+ }
+ if ($usage =~ /u/ || $verb eq "yes"){
+ if ($isVlvNnotes == 0 ){
+ if ($_ =~ /etime= *([0-9.]+)/i ){
+ writeFile($NOTES_A_ETIME, $1);
+ }
+ if ($_ =~ /conn= *([0-9]+)/i){
+ writeFile($NOTES_A_CONN, $1);
+ }
+ if ($_ =~ /op= *([0-9]+)/i){
+ writeFile($NOTES_A_OP, $1);
+ }
+ if ($_ =~ / *([0-9a-z:\/]+)/i){
+ writeFile($NOTES_A_TIME, $1);
+ }
+ if ($_ =~ /nentries= *([0-9]+)/i ){
+ writeFile($NOTES_A_NENTRIES, $1);
+ }
+ }
+ }
+ $isVlvNotes = 0;
+ }
if (m/ notes=U/){
if ($_ =~ /conn= *([0-9]+)/i){
$con = $1;
if ($_ =~ /op= *([0-9]+)/i){ $op = $1;}
}
for ($i=0; $i <= $vlvCount;$i++){
- if ($vlvconn[$i] eq $con && $vlvop[$i] eq $op){ $vlvNotesCount++;
$isVlvNotes="1";}
+ if ($vlvconn[$i] eq $con && $vlvop[$i] eq $op){ $vlvNotesUCount++;
$isVlvNotes="1";}
}
if($isVlvNotes == 0){
# We don't want to record vlv unindexed searches for our regular "bad"
# unindexed search stat, as VLV unindexed searches aren't that bad
- $unindexedSrchCount++;
- if($reportStats){ inc_stats('notesu',$s_stats,$m_stats); }
+ $unindexedSrchCountNotesU++;
+ if($reportStats){ inc_stats('notesU',$s_stats,$m_stats); }
}
if ($usage =~ /u/ || $verb eq "yes"){
if ($isVlvNnotes == 0 ){
if ($_ =~ /etime= *([0-9.]+)/i ){
- writeFile($NOTES_ETIME, $1);
+ writeFile($NOTES_U_ETIME, $1);
}
if ($_ =~ /conn= *([0-9]+)/i){
- writeFile($NOTES_CONN, $1);
+ writeFile($NOTES_U_CONN, $1);
}
if ($_ =~ /op= *([0-9]+)/i){
- writeFile($NOTES_OP, $1);
+ writeFile($NOTES_U_OP, $1);
}
if ($_ =~ / *([0-9a-z:\/]+)/i){
- writeFile($NOTES_TIME, $1);
+ writeFile($NOTES_U_TIME, $1);
}
if ($_ =~ /nentries= *([0-9]+)/i ){
- writeFile($NOTES_NENTRIES, $1);
+ writeFile($NOTES_U_NENTRIES, $1);
}
}
}
@@ -2196,7 +2316,8 @@ reset_stats_block
$stats->{'bind'}=0;
$stats->{'anonbind'}=0;
$stats->{'unbind'}=0;
- $stats->{'notesu'}=0;
+ $stats->{'notesA'}=0;
+ $stats->{'notesU'}=0;
$stats->{'etime'}=0;
return;
}
@@ -2242,13 +2363,14 @@ print_stats_block
$stats->{'bind'},
$stats->{'anonbind'},
$stats->{'unbind'},
- $stats->{'notesu'},
+ $stats->{'notesA'},
+ $stats->{'notesU'},
$stats->{'etime'}),
"\n" );
} else {
$stats->{'fh'}->print(
"Time,time_t,Results,Search,Add,Mod,Modrdn,Moddn,Compare,Delete,Abandon,".
- "Connections,SSL Conns,Bind,Anon Bind,Unbind,Unindexed,ElapsedTime\n"
+ "Connections,SSL Conns,Bind,Anon Bind,Unbind,Unindexed search,Unindexed
component,ElapsedTime\n"
);
}
}
@@ -2415,11 +2537,16 @@ openDataFiles
open($UNBIND_OP, ">$UNBIND_OP") or do { openFailed($!, $UNBIND_OP) };
open($EXT_CONN, ">$EXT_CONN") or do { openFailed($!, $EXT_CONN) };
open($EXT_OP, ">$EXT_OP") or do { openFailed($!, $EXT_OP) };
- open($NOTES_ETIME, ">$NOTES_ETIME") or do { openFailed($!, $NOTES_ETIME)
};
- open($NOTES_CONN, ">$NOTES_CONN") or do { openFailed($!, $NOTES_CONN) };
- open($NOTES_OP, ">$NOTES_OP") or do { openFailed($!, $NOTES_OP) };
- open($NOTES_TIME, ">$NOTES_TIME") or do { openFailed($!, $NOTES_TIME) };
- open($NOTES_NENTRIES, ">$NOTES_NENTRIES") or do { openFailed($!,
$NOTES_NENTRIES) };
+ open($NOTES_A_ETIME, ">$NOTES_A_ETIME") or do { openFailed($!,
$NOTES_A_ETIME) };
+ open($NOTES_A_CONN, ">$NOTES_A_CONN") or do { openFailed($!, $NOTES_A_CONN)
};
+ open($NOTES_A_OP, ">$NOTES_A_OP") or do { openFailed($!, $NOTES_A_OP) };
+ open($NOTES_A_TIME, ">$NOTES_A_TIME") or do { openFailed($!, $NOTES_A_TIME)
};
+ open($NOTES_A_NENTRIES, ">$NOTES_A_NENTRIES") or do { openFailed($!,
$NOTES_A_NENTRIES) };
+ open($NOTES_U_ETIME, ">$NOTES_U_ETIME") or do { openFailed($!,
$NOTES_U_ETIME) };
+ open($NOTES_U_CONN, ">$NOTES_U_CONN") or do { openFailed($!, $NOTES_U_CONN)
};
+ open($NOTES_U_OP, ">$NOTES_U_OP") or do { openFailed($!, $NOTES_U_OP) };
+ open($NOTES_U_TIME, ">$NOTES_U_TIME") or do { openFailed($!, $NOTES_U_TIME)
};
+ open($NOTES_U_NENTRIES, ">$NOTES_U_NENTRIES") or do { openFailed($!,
$NOTES_U_NENTRIES) };
open($BADPWDCONN, ">$BADPWDCONN") or do { openFailed($!, $BADPWDCONN) };
open($BADPWDOP, ">$BADPWDOP") or do { openFailed($!, $BADPWDOP) };
open($BADPWDIP, ">$BADPWDIP") or do { openFailed($!, $NADPWDIP) };
@@ -2473,11 +2600,16 @@ closeDataFiles
close $UNBIND_OP;
close $EXT_CONN;
close $EXT_OP;
- close $NOTES_ETIME;
- close $NOTES_CONN;
- close $NOTES_OP;
- close $NOTES_TIME;
- close $NOTES_NENTRIES;
+ close $NOTES_A_ETIME;
+ close $NOTES_A_CONN;
+ close $NOTES_A_OP;
+ close $NOTES_A_TIME;
+ close $NOTES_A_NENTRIES;
+ close $NOTES_U_ETIME;
+ close $NOTES_U_CONN;
+ close $NOTES_U_OP;
+ close $NOTES_U_TIME;
+ close $NOTES_U_NENTRIES;
close $BADPWDCONN;
close $BADPWDOP;
close $BADPWDIP;
@@ -2531,11 +2663,16 @@ removeDataFiles
unlink $UNBIND_OP;
unlink $EXT_CONN;
unlink $EXT_OP;
- unlink $NOTES_ETIME;
- unlink $NOTES_CONN;
- unlink $NOTES_OP;
- unlink $NOTES_TIME;
- unlink $NOTES_NENTRIES;
+ unlink $NOTES_A_ETIME;
+ unlink $NOTES_A_CONN;
+ unlink $NOTES_A_OP;
+ unlink $NOTES_A_TIME;
+ unlink $NOTES_A_NENTRIES;
+ unlink $NOTES_U_ETIME;
+ unlink $NOTES_U_CONN;
+ unlink $NOTES_U_OP;
+ unlink $NOTES_U_TIME;
+ unlink $NOTES_U_NENTRIES;
unlink $BADPWDCONN;
unlink $BADPWDOP;
unlink $BADPWDIP;
diff --git a/ldap/servers/slapd/back-ldbm/ldbm_search.c
b/ldap/servers/slapd/back-ldbm/ldbm_search.c
index 4b789a2..f70388f 100644
--- a/ldap/servers/slapd/back-ldbm/ldbm_search.c
+++ b/ldap/servers/slapd/back-ldbm/ldbm_search.c
@@ -869,7 +869,7 @@ ldbm_back_search( Slapi_PBlock *pb )
* to record that fact.
*/
if ( NULL != candidates && ALLIDS( candidates )) {
- unsigned int opnote = SLAPI_OP_NOTE_UNINDEXED;
+ unsigned int opnote;
int ri = 0;
int pr_idx = -1;
@@ -892,6 +892,10 @@ ldbm_back_search( Slapi_PBlock *pb )
}
}
+ slapi_pblock_get( pb, SLAPI_OPERATION_NOTES, &opnote );
+ opnote |= SLAPI_OP_NOTE_FULL_UNINDEXED; /* the full filter leads to an unindexed
search */
+ opnote &= ~SLAPI_OP_NOTE_UNINDEXED; /* this note is useless because
FULL_UNINDEXED includes UNINDEXED */
+ slapi_pblock_set( pb, SLAPI_OPERATION_NOTES, NULL );
slapi_pblock_set( pb, SLAPI_OPERATION_NOTES, &opnote );
slapi_pblock_get( pb, SLAPI_PAGED_RESULTS_INDEX, &pr_idx );
pagedresults_set_unindexed( pb->pb_conn, pb->pb_op, pr_idx );
diff --git a/ldap/servers/slapd/result.c b/ldap/servers/slapd/result.c
index 925be53..bdbfd77 100644
--- a/ldap/servers/slapd/result.c
+++ b/ldap/servers/slapd/result.c
@@ -1617,7 +1617,8 @@ struct slapi_note_map {
static struct slapi_note_map notemap[] = {
{ SLAPI_OP_NOTE_UNINDEXED, "U" },
- { SLAPI_OP_NOTE_SIMPLEPAGED, "P" }
+ { SLAPI_OP_NOTE_SIMPLEPAGED, "P" },
+ { SLAPI_OP_NOTE_FULL_UNINDEXED, "A" }
};
#define SLAPI_NOTEMAP_COUNT ( sizeof(notemap) / sizeof(struct slapi_note_map))
diff --git a/ldap/servers/slapd/slapi-plugin.h b/ldap/servers/slapd/slapi-plugin.h
index 5a12a93..26a3a44 100644
--- a/ldap/servers/slapd/slapi-plugin.h
+++ b/ldap/servers/slapd/slapi-plugin.h
@@ -6807,6 +6807,7 @@ typedef struct slapi_plugindesc {
#define SLAPI_OPERATION_NOTES 57
#define SLAPI_OP_NOTE_UNINDEXED 0x01
#define SLAPI_OP_NOTE_SIMPLEPAGED 0x02
+#define SLAPI_OP_NOTE_FULL_UNINDEXED 0x04
/* Allows controls to be passed before operation object is created */
#define SLAPI_CONTROLS_ARG 58