|
Packit |
57988d |
##########################################################################
|
|
Packit |
57988d |
# $Id$
|
|
Packit |
57988d |
##########################################################################
|
|
Packit |
57988d |
|
|
Packit |
57988d |
#######################################################
|
|
Packit |
57988d |
## Copyright (c) 2008 Kirk Bauer
|
|
Packit |
57988d |
## Covered under the included MIT/X-Consortium License:
|
|
Packit |
57988d |
## http://www.opensource.org/licenses/mit-license.php
|
|
Packit |
57988d |
## All modifications and contributions by other persons to
|
|
Packit |
57988d |
## this script are assumed to have been donated to the
|
|
Packit |
57988d |
## Logwatch project and thus assume the above copyright
|
|
Packit |
57988d |
## and licensing terms. If you want to make contributions
|
|
Packit |
57988d |
## under your own copyright or a different license this
|
|
Packit |
57988d |
## must be explicitly stated in the contribution an the
|
|
Packit |
57988d |
## Logwatch project reserves the right to not accept such
|
|
Packit |
57988d |
## contributions. If you have made significant
|
|
Packit |
57988d |
## contributions to this script and want to claim
|
|
Packit |
57988d |
## copyright please contact logwatch-devel@lists.sourceforge.net.
|
|
Packit |
57988d |
#########################################################
|
|
Packit |
57988d |
|
|
Packit |
57988d |
$Detail = $ENV{'LOGWATCH_DETAIL_LEVEL'} || 0;
|
|
Packit |
57988d |
$QmailDetail = $ENV{'qmail_high_detail'};
|
|
Packit |
57988d |
$QmailThreshold = $ENV{'threshold'};
|
|
Packit |
57988d |
$RemoteThreshold = $ENV{'remote_threshold'};
|
|
Packit |
57988d |
$LocalThreshold = $ENV{'local_threshold'};
|
|
Packit |
57988d |
$FromThreshold = $ENV{'from_threshold'};
|
|
Packit |
57988d |
$IgnoreUnmatched = $ENV{'qmail_ignore_unmatched'} || 0;
|
|
Packit |
57988d |
|
|
Packit |
57988d |
while (defined($ThisLine = <STDIN>)) {
|
|
Packit |
57988d |
if (
|
|
Packit |
57988d |
( $ThisLine =~ /new msg/ ) or
|
|
Packit |
57988d |
( $ThisLine =~ /status: / ) or
|
|
Packit |
57988d |
( $ThisLine =~ /bounce msg/ ) or
|
|
Packit |
57988d |
( $ThisLine =~ /triple bounce/ ) or
|
|
Packit |
57988d |
( $ThisLine =~ /tcpserver/ ) or
|
|
Packit |
57988d |
( $ThisLine =~ /end msg/ )
|
|
Packit |
57988d |
) {
|
|
Packit |
57988d |
# We don't care about these
|
|
Packit |
57988d |
} elsif (
|
|
Packit |
57988d |
($msgid,$DeliveryResponse,$Response) = ( $ThisLine =~ /delivery (\d+)\: (.*?)\:(.*)/ )
|
|
Packit |
57988d |
) {
|
|
Packit |
57988d |
if ( $Response =~ /did_/ ) {
|
|
Packit |
57988d |
# ignore these.
|
|
Packit |
57988d |
} else {
|
|
Packit |
57988d |
if ( ($ResponseCode) = ( $Response =~ /Remote_host_said\:_(\d{3})_/ ) ) {
|
|
Packit |
57988d |
$ServerResponses->{$DeliveryResponse}->{$ResponseCode}++;
|
|
Packit |
57988d |
} else {
|
|
Packit |
57988d |
if ( $DeliveryResponse =~ /failure/ ) {
|
|
Packit |
57988d |
$ResponseCode=511;
|
|
Packit |
57988d |
$ServerResponses->{$DeliveryResponse}->{$ResponseCode}++;
|
|
Packit |
57988d |
}
|
|
Packit |
57988d |
if ( $DeliveryResponse =~ /deferral/ ) {
|
|
Packit |
57988d |
$ResponseCode=443;
|
|
Packit |
57988d |
$ServerResponses->{$DeliveryResponse}->{$ResponseCode}++;
|
|
Packit |
57988d |
}
|
|
Packit |
57988d |
}
|
|
Packit |
57988d |
}
|
|
Packit |
57988d |
} elsif ( ($EmailFrom) = ( $ThisLine =~ /from \<(.*)\>/ ) ) {
|
|
Packit |
57988d |
$From{$EmailFrom}++;
|
|
Packit |
57988d |
} elsif ( ($ToLocal) = ( $ThisLine =~ /to local (.*)/ ) ) {
|
|
Packit |
57988d |
$Local{$ToLocal}++;
|
|
Packit |
57988d |
} elsif ( ($ToRemote) = ( $ThisLine =~ /to remote (.*)/ ) ) {
|
|
Packit |
57988d |
$Remote{$ToRemote}++;
|
|
Packit |
57988d |
} else {
|
|
Packit |
57988d |
# Report any unmatched entries...
|
|
Packit |
57988d |
push @OtherList,$ThisLine;
|
|
Packit |
57988d |
}
|
|
Packit |
57988d |
}
|
|
Packit |
57988d |
|
|
Packit |
57988d |
if ($QmailDetail >= 1) {
|
|
Packit |
57988d |
if ($QmailThreshold > 0) {
|
|
Packit |
57988d |
if (($RemoteThreshold < 0) or ($RemoteThreshold eq '')) {
|
|
Packit |
57988d |
$RemoteThreshold = $QmailThreshold;
|
|
Packit |
57988d |
}
|
|
Packit |
57988d |
if (($FromThreshold < 0) or ($FromThreshold eq '')) {
|
|
Packit |
57988d |
$FromThreshold = $QmailThreshold;
|
|
Packit |
57988d |
}
|
|
Packit |
57988d |
if (($LocalThreshold < 0) or ($LocalThreshold eq '')) {
|
|
Packit |
57988d |
$LocalThreshold = $QmailThreshold;
|
|
Packit |
57988d |
}
|
|
Packit |
57988d |
}
|
|
Packit |
57988d |
|
|
Packit |
57988d |
if (($RemoteThreshold < 0) or ($RemoteThreshold eq '')) {
|
|
Packit |
57988d |
$RemoteThreshold = 0;
|
|
Packit |
57988d |
}
|
|
Packit |
57988d |
if (($FromThreshold < 0) or ($FromThreshold eq '')) {
|
|
Packit |
57988d |
$FromThreshold = 0;
|
|
Packit |
57988d |
}
|
|
Packit |
57988d |
if (($LocalThreshold < 0) or ($LocalThreshold eq '')) {
|
|
Packit |
57988d |
$LocalThreshold = 0;
|
|
Packit |
57988d |
}
|
|
Packit |
57988d |
|
|
Packit |
57988d |
if ( (keys %From) ) {
|
|
Packit |
57988d |
print "\nEmails from (Threshold of " . $FromThreshold . "):\n";
|
|
Packit |
57988d |
$threshold_reached=0;
|
|
Packit |
57988d |
foreach $Line (sort {$a cmp $b} keys %From) {
|
|
Packit |
57988d |
if ($From{$Line} >= $FromThreshold) {
|
|
Packit |
57988d |
$threshold_reached=1;
|
|
Packit |
57988d |
print "\t" . $Line . " - ". $From{$Line} . " Time(s)\n";
|
|
Packit |
57988d |
}
|
|
Packit |
57988d |
}
|
|
Packit |
57988d |
if ($threshold_reached < 1) {
|
|
Packit |
57988d |
print "\t" . "None found above the threshold\n";
|
|
Packit |
57988d |
}
|
|
Packit |
57988d |
}
|
|
Packit |
57988d |
|
|
Packit |
57988d |
if ( (keys %Remote) ) {
|
|
Packit |
57988d |
print "\nEmails to Remote Server (Threshold of " . $RemoteThreshold . "):\n";
|
|
Packit |
57988d |
$threshold_reached=0;
|
|
Packit |
57988d |
foreach $Line (sort {$a cmp $b} keys %Remote) {
|
|
Packit |
57988d |
if ($Remote{$Line} >= $RemoteThreshold) {
|
|
Packit |
57988d |
$threshold_reached=1;
|
|
Packit |
57988d |
print "\t" . $Line . " - ". $Remote{$Line} . " Time(s)\n";
|
|
Packit |
57988d |
}
|
|
Packit |
57988d |
}
|
|
Packit |
57988d |
if ($threshold_reached < 1) {
|
|
Packit |
57988d |
print "\t" . "None found above the threshold\n";
|
|
Packit |
57988d |
}
|
|
Packit |
57988d |
}
|
|
Packit |
57988d |
|
|
Packit |
57988d |
if ( (keys %Local) ) {
|
|
Packit |
57988d |
print "\nEmails to Local Server (Threshold of " . $LocalThreshold . "):\n";
|
|
Packit |
57988d |
$threshold_reached=0;
|
|
Packit |
57988d |
foreach $Line (sort {$a cmp $b} keys %Local) {
|
|
Packit |
57988d |
if ($Local{$Line} >= $LocalThreshold) {
|
|
Packit |
57988d |
$threshold_reached=1;
|
|
Packit |
57988d |
print "\t" . $Line . " - ". $Local{$Line} . " Time(s)\n";
|
|
Packit |
57988d |
}
|
|
Packit |
57988d |
}
|
|
Packit |
57988d |
if ($threshold_reached < 1) {
|
|
Packit |
57988d |
print "\t" . "None found above the threshold\n";
|
|
Packit |
57988d |
}
|
|
Packit |
57988d |
}
|
|
Packit |
57988d |
}
|
|
Packit |
57988d |
|
|
Packit |
57988d |
if (keys %{$ServerResponses}) {
|
|
Packit |
57988d |
print "\nRemote Server Responses:\n";
|
|
Packit |
57988d |
foreach $Line (sort {$a cmp $b} keys %{$ServerResponses}) {
|
|
Packit |
57988d |
foreach $Detail (sort {$a cmp $b} keys %{$ServerResponses->{$Line}}) {
|
|
Packit |
57988d |
$ServerResponseTotal{$Line} += $ServerResponses->{$Line}->{$Detail};
|
|
Packit |
57988d |
$ServerResponseOverallTotal += $ServerResponses->{$Line}->{$Detail};
|
|
Packit |
57988d |
print "\t".ucfirst($Line)."(" . $Detail . ") - ". $ServerResponses->{$Line}->{$Detail} . " Time(s)\n";
|
|
Packit |
57988d |
}
|
|
Packit |
57988d |
}
|
|
Packit |
57988d |
print "\n\tPercentage(s):\n";
|
|
Packit |
57988d |
foreach $Details (sort {$a cmp $b} keys %ServerResponseTotal) {
|
|
Packit |
57988d |
$percentage = (($ServerResponseTotal{$Details} / $ServerResponseOverallTotal) * 100);
|
|
Packit |
57988d |
print "\t\t" . ucfirst($Details) . " - ";
|
|
Packit |
57988d |
printf("%.2f",$percentage);
|
|
Packit |
57988d |
print " %\n";
|
|
Packit |
57988d |
}
|
|
Packit |
57988d |
}
|
|
Packit |
57988d |
|
|
Packit |
57988d |
if (($#OtherList >= 0) and (not $IgnoreUnmatched)){
|
|
Packit |
57988d |
print "\n**Unmatched Entries**\n";
|
|
Packit |
57988d |
print @OtherList;
|
|
Packit |
57988d |
}
|
|
Packit |
57988d |
|
|
Packit |
57988d |
exit(0);
|
|
Packit |
57988d |
|
|
Packit |
57988d |
# vi: shiftwidth=3 tabstop=3 syntax=perl et
|
|
Packit |
57988d |
# Local Variables:
|
|
Packit |
57988d |
# mode: perl
|
|
Packit |
57988d |
# perl-indent-level: 3
|
|
Packit |
57988d |
# indent-tabs-mode: nil
|
|
Packit |
57988d |
# End:
|